Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.
Permalink
Browse files Browse the repository at this point in the history
Put 6 bytes of random in tmp folder name
Closes #3635
  • Loading branch information
isaacs committed Jul 10, 2013
1 parent e300730 commit f4d3169
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/npm.js
Expand Up @@ -477,9 +477,14 @@ Object.defineProperty(npm, "cache",
})

var tmpFolder
var crypto = require("crypto")
var rand = crypto.randomBytes(6)
.toString("base64")
.replace(/\//g, '_')
.replace(/\+/, '-')
Object.defineProperty(npm, "tmp",
{ get : function () {
if (!tmpFolder) tmpFolder = "npm-" + process.pid
if (!tmpFolder) tmpFolder = "npm-" + process.pid + "-" + rand
return path.resolve(npm.config.get("tmp"), tmpFolder)
}
, enumerable : true
Expand Down

0 comments on commit f4d3169

Please sign in to comment.