Browse files

Put 6 bytes of random in tmp folder name

Closes #3635
1 parent e300730 commit f4d31693e73a963574a88000580db1a716fe66f1 @isaacs isaacs committed Jul 10, 2013
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/npm.js
View
7 lib/npm.js
@@ -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

0 comments on commit f4d3169

Please sign in to comment.