Skip to content

Commit

Permalink
fix: resolve both target and entry path
Browse files Browse the repository at this point in the history
  • Loading branch information
Danny Grander committed Apr 24, 2018
1 parent 18c3d31 commit 38cb4a4
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 38cb4a4

Please sign in to comment.