File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -272,13 +272,17 @@ exports.extract = function (cwd, opts) {
272
272
xfs . unlink ( name , function ( ) {
273
273
var srcpath = path . join ( cwd , path . join ( '/' , header . linkname ) )
274
274
275
- xfs . link ( srcpath , name , function ( err ) {
276
- if ( err && err . code === 'EPERM' && opts . hardlinkAsFilesFallback ) {
277
- stream = xfs . createReadStream ( srcpath )
278
- return onfile ( )
279
- }
275
+ xfs . realpath ( srcpath , function ( err , dst ) {
276
+ if ( err || ! dst . startsWith ( path . resolve ( cwd ) ) ) return next ( new Error ( name + ' is not a valid hardlink' ) )
280
277
281
- stat ( err )
278
+ xfs . link ( dst , name , function ( err ) {
279
+ if ( err && err . code === 'EPERM' && opts . hardlinkAsFilesFallback ) {
280
+ stream = xfs . createReadStream ( srcpath )
281
+ return onfile ( )
282
+ }
283
+
284
+ stat ( err )
285
+ } )
282
286
} )
283
287
} )
284
288
}
You can’t perform that action at this time.
0 commit comments