From 459056367d6df12a3eaea1555fa091e8a6b08329 Mon Sep 17 00:00:00 2001 From: asylumfunk Date: Tue, 28 Jan 2014 16:19:39 -0800 Subject: [PATCH] lock client in chroot jail fix #5 --- lib/ftpd.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/ftpd.js b/lib/ftpd.js index 41d0c96..5da4d1e 100644 --- a/lib/ftpd.js +++ b/lib/ftpd.js @@ -24,15 +24,15 @@ var starttls = require('./starttls'); - maybe just for milesplit's use? */ -function withCwd(cwd, p) { - if (!cwd) - return p; - else if (!p) - return cwd; - else if (p.length > 0 && (p.charAt(0) == '/' || p.charAt(0) == pathModule.sep)) - return p; - else - return pathModule.join(cwd, p); +function withCwd(cwd, path) { + var firstChar = (path || '').charAt(0); + cwd = cwd || pathModule.sep; + path = path || pathModule.sep; + if (firstChar === '/' || firstChar === pathModule.sep) { + cwd = pathModule.sep; + } + path = pathModule.join(cwd, path); + return path; } // Currently used for stripping options from beginning of argument to LIST and NLST.