Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
path: fix slice OOB in trim
Browse files Browse the repository at this point in the history
Internal function trim(arr). 2nd parameter of slice() should be slice's
end index (not included). Because of function normalize() (called before
trim()), "start" is always zero so the bug -for now- has no effect, but
its a bug waiting to happen.

Reviewed-by: Trevor Norris <trev.norris@gmail.com>
  • Loading branch information
luciotato authored and trevnorris committed Aug 2, 2014
1 parent aab126b commit 37c2a52
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ if (isWindows) {
}

if (start > end) return [];
return arr.slice(start, end - start + 1);
return arr.slice(start, end + 1);
}

var toParts = trim(to.split('\\'));
Expand Down Expand Up @@ -413,7 +413,7 @@ if (isWindows) {
}

if (start > end) return [];
return arr.slice(start, end - start + 1);
return arr.slice(start, end + 1);
}

var fromParts = trim(from.split('/'));
Expand Down

0 comments on commit 37c2a52

Please sign in to comment.