Skip to content

Commit df4bca5

Browse files
committed
port fix from main
1 parent 873cda1 commit df4bca5

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ exports.extract = function (cwd, opts) {
254254
var onsymlink = function () {
255255
if (win32) return next() // skip symlinks on win for now before it can be tested
256256
xfs.unlink(name, function () {
257+
var dst = path.resolve(path.dirname(name), header.linkname)
258+
if (!dst.startsWith(path.resolve(cwd))) return next(new Error(name + ' is not a valid symlink'))
257259
xfs.symlink(header.linkname, name, stat)
258260
})
259261
}

test/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ test('do not extract invalid tar', function (t) {
304304
fs.createReadStream(a)
305305
.pipe(tar.extract(out))
306306
.on('error', function (err) {
307-
t.ok(/is not a valid path/i.test(err.message))
307+
t.ok(/is not a valid symlink/i.test(err.message))
308308
fs.stat(path.join(out, '../bar'), function (err) {
309309
t.ok(err)
310310
t.end()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy