Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit23312ce

Browse files
committed
drop dirCache for symlink on all platforms
1 parent4f1f4a2 commit23312ce

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

‎lib/unpack.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -550,13 +550,13 @@ class Unpack extends Parser {
550550
// then that means we are about to delete the directory we created
551551
// previously, and it is no longer going to be a directory, and neither
552552
// is any of its children.
553-
// If a symbolic link is encountered on Windows, all bets are off.
554-
//There is noreasonable way to sanitize the cache in such a way
555-
//we will be able toavoid having filesystem collisions. If this
556-
//happens with a non-symlinkentry, it'll just fail to unpack,
557-
//but a symlink to a directory, using an 8.3 shortname, can evade
558-
//detection and leadto arbitrary writes to anywhere on the system.
559-
if(isWindows&&entry.type==='SymbolicLink')
553+
// If a symbolic link is encountered, all bets are off. There is no
554+
// reasonable way to sanitize the cache in such a way we will be able to
555+
// avoid having filesystem collisions. If this happens with a non-symlink
556+
// entry, it'll just fail to unpack, but a symlink to a directory, using an
557+
//8.3 shortname or certain unicode attacks, can evade detection and lead
558+
// to arbitrary writes to anywhere on the system.
559+
if(entry.type==='SymbolicLink')
560560
dropCache(this.dirCache)
561561
elseif(entry.type!=='Directory')
562562
pruneCache(this.dirCache,entry.absolute)

‎test/unpack.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3027,6 +3027,10 @@ t.test('dirCache pruning unicode normalized collisions', {
30273027
path:Buffer.from([0x63,0x61,0x66,0x65,0xcc,0x81]).toString(),
30283028
linkpath:'foo',
30293029
},
3030+
{
3031+
type:'Directory',
3032+
path:'foo',
3033+
},
30303034
{
30313035
type:'File',
30323036
path:Buffer.from([0x63,0x61,0x66,0xc3,0xa9]).toString()+'/bar',
@@ -3040,7 +3044,6 @@ t.test('dirCache pruning unicode normalized collisions', {
30403044
constcheck=(path,dirCache,t)=>{
30413045
path=path.replace(/\\/g,'/')
30423046
t.strictSame([...dirCache.entries()],[
3043-
[path,true],
30443047
[`${path}/foo`,true],
30453048
])
30463049
t.equal(fs.readFileSync(path+'/foo/bar','utf8'),'x')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp