Skip to content

Commit

Permalink
Merge pull request #215 from grnd/master
Browse files Browse the repository at this point in the history
fix: resolve both target and entry path
  • Loading branch information
cthackers committed Apr 25, 2018
2 parents 18c3d31 + 38cb4a4 commit ce59e5a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions adm-zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ module.exports = function(/*String*/input) {


var target = pth.resolve(targetPath, maintainEntryPath ? entryName : pth.basename(entryName));
if(!target.startsWith(targetPath)) {
if(!pth.resolve(target).startsWith(pth.resolve(targetPath))) {
throw Utils.Errors.INVALID_FILENAME + ": " + entryName;
}

Expand Down Expand Up @@ -432,7 +432,7 @@ module.exports = function(/*String*/input) {
_zip.entries.forEach(function(entry) {
entryName = entry.entryName.toString();

if(!pth.resolve(targetPath, entryName).startsWith(targetPath)) {
if(!pth.resolve(targetPath, entryName).startsWith(pth.resolve(targetPath))) {
throw Utils.Errors.INVALID_FILENAME + ": " + entryName;
}

Expand Down Expand Up @@ -478,7 +478,7 @@ module.exports = function(/*String*/input) {
entryName = escapeFileName(entryName)
}

if(!pth.resolve(targetPath, entryName).startsWith(targetPath)) {
if(!pth.resolve(targetPath, entryName).startsWith(pth.resolve(targetPath))) {
throw Utils.Errors.INVALID_FILENAME + ": " + entryName;
}

Expand Down

0 comments on commit ce59e5a

Please sign in to comment.