tar 4.4.14 → 4.4.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/unpack.js CHANGED
@@ -1,5 +1,11 @@
1
1
  'use strict'
2
2
 
3
+ // the PEND/UNPEND stuff tracks whether we're ready to emit end/close yet.
4
+ // but the path reservations are required to avoid race conditions where
5
+ // parallelized unpack ops may mess with one another, due to dependencies
6
+ // (like a Link depending on its target) or destructive operations (like
7
+ // clobbering an fs object to create one of a different type.)
8
+
3
9
  const assert = require('assert')
4
10
  const EE = require('events').EventEmitter
5
11
  const Parser = require('./parse.js')
@@ -10,9 +16,14 @@ const mkdir = require('./mkdir.js')
10
16
  const mkdirSync = mkdir.sync
11
17
  const wc = require('./winchars.js')
12
18
  const stripAbsolutePath = require('./strip-absolute-path.js')
19
+ const pathReservations = require('./path-reservations.js')
20
+ const normPath = require('./normalize-windows-path.js')
21
+ const stripSlash = require('./strip-trailing-slashes.js')
13
22
 
14
23
  const ONENTRY = Symbol('onEntry')
15
24
  const CHECKFS = Symbol('checkFs')
25
+ const CHECKFS2 = Symbol('checkFs2')
26
+ const PRUNECACHE = Symbol('pruneCache')
16
27
  const ISREUSABLE = Symbol('isReusable')
17
28
  const MAKEFS = Symbol('makeFs')
18
29
  const FILE = Symbol('file')
@@ -34,7 +45,10 @@ const SKIP = Symbol('skip')
34
45
  const DOCHOWN = Symbol('doChown')
35
46
  const UID = Symbol('uid')
36
47
  const GID = Symbol('gid')
48
+ const CHECKED_CWD = Symbol('checkedCwd')
37
49
  const crypto = require('crypto')
50
+ const platform = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform
51
+ const isWindows = platform === 'win32'
38
52
 
39
53
  // Unlinks on Windows are not atomic.
40
54
  //
@@ -53,7 +67,7 @@ const crypto = require('crypto')
53
67
  // See: https://github.com/npm/node-tar/issues/183
54
68
  /* istanbul ignore next */
55
69
  const unlinkFile = (path, cb) => {
56
- if (process.platform !== 'win32')
70
+ if (!isWindows)
57
71
  return fs.unlink(path, cb)
58
72
 
59
73
  const name = path + '.DELETE.' + crypto.randomBytes(16).toString('hex')
@@ -66,7 +80,7 @@ const unlinkFile = (path, cb) => {
66
80
 
67
81
  /* istanbul ignore next */
68
82
  const unlinkFileSync = path => {
69
- if (process.platform !== 'win32')
83
+ if (!isWindows)
70
84
  return fs.unlinkSync(path)
71
85
 
72
86
  const name = path + '.DELETE.' + crypto.randomBytes(16).toString('hex')
@@ -80,6 +94,33 @@ const uint32 = (a, b, c) =>
80
94
  : b === b >>> 0 ? b
81
95
  : c
82
96
 
97
+ // clear the cache if it's a case-insensitive unicode-squashing match.
98
+ // we can't know if the current file system is case-sensitive or supports
99
+ // unicode fully, so we check for similarity on the maximally compatible
100
+ // representation. Err on the side of pruning, since all it's doing is
101
+ // preventing lstats, and it's not the end of the world if we get a false
102
+ // positive.
103
+ // Note that on windows, we always drop the entire cache whenever a
104
+ // symbolic link is encountered, because 8.3 filenames are impossible
105
+ // to reason about, and collisions are hazards rather than just failures.
106
+ const cacheKeyNormalize = path => stripSlash(normPath(path))
107
+ .normalize('NFKD')
108
+ .toLowerCase()
109
+
110
+ const pruneCache = (cache, abs) => {
111
+ abs = cacheKeyNormalize(abs)
112
+ for (const path of cache.keys()) {
113
+ const pnorm = cacheKeyNormalize(path)
114
+ if (pnorm === abs || pnorm.indexOf(abs + '/') === 0)
115
+ cache.delete(path)
116
+ }
117
+ }
118
+
119
+ const dropCache = cache => {
120
+ for (const key of cache.keys())
121
+ cache.delete(key)
122
+ }
123
+
83
124
  class Unpack extends Parser {
84
125
  constructor (opt) {
85
126
  if (!opt)
@@ -92,6 +133,10 @@ class Unpack extends Parser {
92
133
 
93
134
  super(opt)
94
135
 
136
+ this[CHECKED_CWD] = false
137
+
138
+ this.reservations = pathReservations()
139
+
95
140
  this.transform = typeof opt.transform === 'function' ? opt.transform : null
96
141
 
97
142
  this.writable = true
@@ -134,7 +179,7 @@ class Unpack extends Parser {
134
179
  this.forceChown = opt.forceChown === true
135
180
 
136
181
  // turn ><?| in filenames into 0xf000-higher encoded forms
137
- this.win32 = !!opt.win32 || process.platform === 'win32'
182
+ this.win32 = !!opt.win32 || isWindows
138
183
 
139
184
  // do not unpack over files that are newer than what's in the archive
140
185
  this.newer = !!opt.newer
@@ -154,7 +199,7 @@ class Unpack extends Parser {
154
199
  // links, and removes symlink directories rather than erroring
155
200
  this.unlink = !!opt.unlink
156
201
 
157
- this.cwd = path.resolve(opt.cwd || process.cwd())
202
+ this.cwd = normPath(path.resolve(opt.cwd || process.cwd()))
158
203
  this.strip = +opt.strip || 0
159
204
  this.processUmask = process.umask()
160
205
  this.umask = typeof opt.umask === 'number' ? opt.umask : this.processUmask
@@ -175,27 +220,29 @@ class Unpack extends Parser {
175
220
 
176
221
  [CHECKPATH] (entry) {
177
222
  if (this.strip) {
178
- const parts = entry.path.split(/\/|\\/)
223
+ const parts = normPath(entry.path).split('/')
179
224
  if (parts.length < this.strip)
180
225
  return false
181
226
  entry.path = parts.slice(this.strip).join('/')
182
227
 
183
228
  if (entry.type === 'Link') {
184
- const linkparts = entry.linkpath.split(/\/|\\/)
229
+ const linkparts = normPath(entry.linkpath).split('/')
185
230
  if (linkparts.length >= this.strip)
186
231
  entry.linkpath = linkparts.slice(this.strip).join('/')
232
+ else
233
+ return false
187
234
  }
188
235
  }
189
236
 
190
237
  if (!this.preservePaths) {
191
- const p = entry.path
192
- if (p.match(/(^|\/|\\)\.\.(\\|\/|$)/)) {
193
- this.warn('path contains \'..\'', p)
238
+ const p = normPath(entry.path)
239
+ const parts = p.split('/')
240
+ if (parts.includes('..') || isWindows && /^[a-z]:\.\.$/i.test(parts[0])) {
241
+ this.warn(`path contains '..'`, p)
194
242
  return false
195
243
  }
196
244
 
197
- // absolutes on posix are also absolutes on win32
198
- // so we only need to test this one to get both
245
+ // strip off the root
199
246
  const s = stripAbsolutePath(p)
200
247
  if (s[0]) {
201
248
  entry.path = s[1]
@@ -203,18 +250,42 @@ class Unpack extends Parser {
203
250
  }
204
251
  }
205
252
 
253
+ if (path.isAbsolute(entry.path))
254
+ entry.absolute = normPath(path.resolve(entry.path))
255
+ else
256
+ entry.absolute = normPath(path.resolve(this.cwd, entry.path))
257
+
258
+ // if we somehow ended up with a path that escapes the cwd, and we are
259
+ // not in preservePaths mode, then something is fishy! This should have
260
+ // been prevented above, so ignore this for coverage.
261
+ /* istanbul ignore if - defense in depth */
262
+ if (!this.preservePaths &&
263
+ entry.absolute.indexOf(this.cwd + '/') !== 0 &&
264
+ entry.absolute !== this.cwd) {
265
+ this.warn('TAR_ENTRY_ERROR', 'path escaped extraction target', {
266
+ entry,
267
+ path: normPath(entry.path),
268
+ resolvedPath: entry.absolute,
269
+ cwd: this.cwd,
270
+ })
271
+ return false
272
+ }
273
+
274
+ // an archive can set properties on the extraction directory, but it
275
+ // may not replace the cwd with a different kind of thing entirely.
276
+ if (entry.absolute === this.cwd &&
277
+ entry.type !== 'Directory' &&
278
+ entry.type !== 'GNUDumpDir')
279
+ return false
280
+
206
281
  // only encode : chars that aren't drive letter indicators
207
282
  if (this.win32) {
208
- const parsed = path.win32.parse(entry.path)
209
- entry.path = parsed.root === '' ? wc.encode(entry.path)
210
- : parsed.root + wc.encode(entry.path.substr(parsed.root.length))
283
+ const { root: aRoot } = path.win32.parse(entry.absolute)
284
+ entry.absolute = aRoot + wc.encode(entry.absolute.substr(aRoot.length))
285
+ const { root: pRoot } = path.win32.parse(entry.path)
286
+ entry.path = pRoot + wc.encode(entry.path.substr(pRoot.length))
211
287
  }
212
288
 
213
- if (path.isAbsolute(entry.path))
214
- entry.absolute = entry.path
215
- else
216
- entry.absolute = path.resolve(this.cwd, entry.path)
217
-
218
289
  return true
219
290
  }
220
291
 
@@ -258,7 +329,7 @@ class Unpack extends Parser {
258
329
  }
259
330
 
260
331
  [MKDIR] (dir, mode, cb) {
261
- mkdir(dir, {
332
+ mkdir(normPath(dir), {
262
333
  uid: this.uid,
263
334
  gid: this.gid,
264
335
  processUid: this.processUid,
@@ -292,21 +363,44 @@ class Unpack extends Parser {
292
363
  return uint32(this.gid, entry.gid, this.processGid)
293
364
  }
294
365
 
295
- [FILE] (entry) {
366
+ [FILE] (entry, fullyDone) {
296
367
  const mode = entry.mode & 0o7777 || this.fmode
297
368
  const stream = new fsm.WriteStream(entry.absolute, {
298
369
  mode: mode,
299
370
  autoClose: false
300
371
  })
301
- stream.on('error', er => this[ONERROR](er, entry))
372
+ stream.on('error', er => {
373
+ if (stream.fd)
374
+ fs.close(stream.fd, () => {})
375
+
376
+ // flush all the data out so that we aren't left hanging
377
+ // if the error wasn't actually fatal. otherwise the parse
378
+ // is blocked, and we never proceed.
379
+ /* istanbul ignore next */
380
+ stream.write = () => true
381
+ this[ONERROR](er, entry)
382
+ fullyDone()
383
+ })
302
384
 
303
385
  let actions = 1
304
386
  const done = er => {
305
- if (er)
306
- return this[ONERROR](er, entry)
387
+ if (er) {
388
+ /* istanbul ignore else - we should always have a fd by now */
389
+ if (stream.fd)
390
+ fs.close(stream.fd, () => {})
307
391
 
308
- if (--actions === 0)
309
- fs.close(stream.fd, _ => this[UNPEND]())
392
+ this[ONERROR](er, entry)
393
+ fullyDone()
394
+ return
395
+ }
396
+
397
+ if (--actions === 0) {
398
+ fs.close(stream.fd, er => {
399
+ fullyDone()
400
+ /* istanbul ignore next */
401
+ er ? this[ONERROR](er, entry) : this[UNPEND]()
402
+ })
403
+ }
310
404
  }
311
405
 
312
406
  stream.on('finish', _ => {
@@ -345,15 +439,18 @@ class Unpack extends Parser {
345
439
  tx.pipe(stream)
346
440
  }
347
441
 
348
- [DIRECTORY] (entry) {
442
+ [DIRECTORY] (entry, fullyDone) {
349
443
  const mode = entry.mode & 0o7777 || this.dmode
350
444
  this[MKDIR](entry.absolute, mode, er => {
351
- if (er)
445
+ if (er) {
446
+ fullyDone()
352
447
  return this[ONERROR](er, entry)
448
+ }
353
449
 
354
450
  let actions = 1
355
451
  const done = _ => {
356
452
  if (--actions === 0) {
453
+ fullyDone()
357
454
  this[UNPEND]()
358
455
  entry.resume()
359
456
  }
@@ -378,12 +475,13 @@ class Unpack extends Parser {
378
475
  entry.resume()
379
476
  }
380
477
 
381
- [SYMLINK] (entry) {
382
- this[LINK](entry, entry.linkpath, 'symlink')
478
+ [SYMLINK] (entry, done) {
479
+ this[LINK](entry, entry.linkpath, 'symlink', done)
383
480
  }
384
481
 
385
- [HARDLINK] (entry) {
386
- this[LINK](entry, path.resolve(this.cwd, entry.linkpath), 'link')
482
+ [HARDLINK] (entry, done) {
483
+ const linkpath = normPath(path.resolve(this.cwd, entry.linkpath))
484
+ this[LINK](entry, linkpath, 'link', done)
387
485
  }
388
486
 
389
487
  [PEND] () {
@@ -408,35 +506,122 @@ class Unpack extends Parser {
408
506
  !this.unlink &&
409
507
  st.isFile() &&
410
508
  st.nlink <= 1 &&
411
- process.platform !== 'win32'
509
+ !isWindows
412
510
  }
413
511
 
414
512
  // check if a thing is there, and if so, try to clobber it
415
513
  [CHECKFS] (entry) {
416
514
  this[PEND]()
417
- this[MKDIR](path.dirname(entry.absolute), this.dmode, er => {
418
- if (er)
419
- return this[ONERROR](er, entry)
420
- fs.lstat(entry.absolute, (er, st) => {
421
- if (st && (this.keep || this.newer && st.mtime > entry.mtime))
515
+ const paths = [entry.path]
516
+ if (entry.linkpath)
517
+ paths.push(entry.linkpath)
518
+ this.reservations.reserve(paths, done => this[CHECKFS2](entry, done))
519
+ }
520
+
521
+ [PRUNECACHE] (entry) {
522
+ // if we are not creating a directory, and the path is in the dirCache,
523
+ // then that means we are about to delete the directory we created
524
+ // previously, and it is no longer going to be a directory, and neither
525
+ // is any of its children.
526
+ // If a symbolic link is encountered on Windows, all bets are off.
527
+ // There is no reasonable way to sanitize the cache in such a way
528
+ // we will be able to avoid having filesystem collisions. If this
529
+ // happens with a non-symlink entry, it'll just fail to unpack,
530
+ // but a symlink to a directory, using an 8.3 shortname, can evade
531
+ // detection and lead to arbitrary writes to anywhere on the system.
532
+ if (isWindows && entry.type === 'SymbolicLink')
533
+ dropCache(this.dirCache)
534
+ else if (entry.type !== 'Directory')
535
+ pruneCache(this.dirCache, entry.absolute)
536
+ }
537
+
538
+ [CHECKFS2] (entry, fullyDone) {
539
+ this[PRUNECACHE](entry)
540
+
541
+ const done = er => {
542
+ this[PRUNECACHE](entry)
543
+ fullyDone(er)
544
+ }
545
+
546
+ const checkCwd = () => {
547
+ this[MKDIR](this.cwd, this.dmode, er => {
548
+ if (er) {
549
+ this[ONERROR](er, entry)
550
+ done()
551
+ return
552
+ }
553
+ this[CHECKED_CWD] = true
554
+ start()
555
+ })
556
+ }
557
+
558
+ const start = () => {
559
+ if (entry.absolute !== this.cwd) {
560
+ const parent = normPath(path.dirname(entry.absolute))
561
+ if (parent !== this.cwd) {
562
+ return this[MKDIR](parent, this.dmode, er => {
563
+ if (er) {
564
+ this[ONERROR](er, entry)
565
+ done()
566
+ return
567
+ }
568
+ afterMakeParent()
569
+ })
570
+ }
571
+ }
572
+ afterMakeParent()
573
+ }
574
+
575
+ const afterMakeParent = () => {
576
+ fs.lstat(entry.absolute, (lstatEr, st) => {
577
+ if (st && (this.keep || this.newer && st.mtime > entry.mtime)) {
422
578
  this[SKIP](entry)
423
- else if (er || this[ISREUSABLE](entry, st))
424
- this[MAKEFS](null, entry)
425
- else if (st.isDirectory()) {
579
+ done()
580
+ return
581
+ }
582
+ if (lstatEr || this[ISREUSABLE](entry, st))
583
+ return this[MAKEFS](null, entry, done)
584
+
585
+ if (st.isDirectory()) {
426
586
  if (entry.type === 'Directory') {
427
- if (!entry.mode || (st.mode & 0o7777) === entry.mode)
428
- this[MAKEFS](null, entry)
429
- else
430
- fs.chmod(entry.absolute, entry.mode, er => this[MAKEFS](er, entry))
431
- } else
432
- fs.rmdir(entry.absolute, er => this[MAKEFS](er, entry))
433
- } else
434
- unlinkFile(entry.absolute, er => this[MAKEFS](er, entry))
587
+ const needChmod = !this.noChmod &&
588
+ entry.mode &&
589
+ (st.mode & 0o7777) !== entry.mode
590
+ const afterChmod = er => this[MAKEFS](er, entry, done)
591
+ if (!needChmod)
592
+ return afterChmod()
593
+ return fs.chmod(entry.absolute, entry.mode, afterChmod)
594
+ }
595
+ // Not a dir entry, have to remove it.
596
+ // NB: the only way to end up with an entry that is the cwd
597
+ // itself, in such a way that == does not detect, is a
598
+ // tricky windows absolute path with UNC or 8.3 parts (and
599
+ // preservePaths:true, or else it will have been stripped).
600
+ // In that case, the user has opted out of path protections
601
+ // explicitly, so if they blow away the cwd, c'est la vie.
602
+ if (entry.absolute !== this.cwd) {
603
+ return fs.rmdir(entry.absolute, er =>
604
+ this[MAKEFS](er, entry, done))
605
+ }
606
+ }
607
+
608
+ // not a dir, and not reusable
609
+ // don't remove if the cwd, we want that error
610
+ if (entry.absolute === this.cwd)
611
+ return this[MAKEFS](null, entry, done)
612
+
613
+ unlinkFile(entry.absolute, er =>
614
+ this[MAKEFS](er, entry, done))
435
615
  })
436
- })
616
+ }
617
+
618
+ if (this[CHECKED_CWD])
619
+ start()
620
+ else
621
+ checkCwd()
437
622
  }
438
623
 
439
- [MAKEFS] (er, entry) {
624
+ [MAKEFS] (er, entry, done) {
440
625
  if (er)
441
626
  return this[ONERROR](er, entry)
442
627
 
@@ -444,73 +629,107 @@ class Unpack extends Parser {
444
629
  case 'File':
445
630
  case 'OldFile':
446
631
  case 'ContiguousFile':
447
- return this[FILE](entry)
632
+ return this[FILE](entry, done)
448
633
 
449
634
  case 'Link':
450
- return this[HARDLINK](entry)
635
+ return this[HARDLINK](entry, done)
451
636
 
452
637
  case 'SymbolicLink':
453
- return this[SYMLINK](entry)
638
+ return this[SYMLINK](entry, done)
454
639
 
455
640
  case 'Directory':
456
641
  case 'GNUDumpDir':
457
- return this[DIRECTORY](entry)
642
+ return this[DIRECTORY](entry, done)
458
643
  }
459
644
  }
460
645
 
461
- [LINK] (entry, linkpath, link) {
462
- // XXX: get the type ('file' or 'dir') for windows
646
+ [LINK] (entry, linkpath, link, done) {
647
+ // XXX: get the type ('symlink' or 'junction') for windows
463
648
  fs[link](linkpath, entry.absolute, er => {
464
649
  if (er)
465
650
  return this[ONERROR](er, entry)
651
+ done()
466
652
  this[UNPEND]()
467
653
  entry.resume()
468
654
  })
469
655
  }
470
656
  }
471
657
 
658
+ const callSync = fn => {
659
+ try {
660
+ return [null, fn()]
661
+ } catch (er) {
662
+ return [er, null]
663
+ }
664
+ }
472
665
  class UnpackSync extends Unpack {
473
- constructor (opt) {
474
- super(opt)
666
+ [MAKEFS] (er, entry) {
667
+ return super[MAKEFS](er, entry, /* istanbul ignore next */ () => {})
475
668
  }
476
669
 
477
670
  [CHECKFS] (entry) {
478
- const er = this[MKDIR](path.dirname(entry.absolute), this.dmode)
479
- if (er)
480
- return this[ONERROR](er, entry)
481
- try {
482
- const st = fs.lstatSync(entry.absolute)
483
- if (this.keep || this.newer && st.mtime > entry.mtime)
484
- return this[SKIP](entry)
485
- else if (this[ISREUSABLE](entry, st))
486
- return this[MAKEFS](null, entry)
487
- else {
488
- try {
489
- if (st.isDirectory()) {
490
- if (entry.type === 'Directory') {
491
- if (entry.mode && (st.mode & 0o7777) !== entry.mode)
492
- fs.chmodSync(entry.absolute, entry.mode)
493
- } else
494
- fs.rmdirSync(entry.absolute)
495
- } else
496
- unlinkFileSync(entry.absolute)
497
- return this[MAKEFS](null, entry)
498
- } catch (er) {
499
- return this[ONERROR](er, entry)
500
- }
671
+ this[PRUNECACHE](entry)
672
+
673
+ if (!this[CHECKED_CWD]) {
674
+ const er = this[MKDIR](this.cwd, this.dmode)
675
+ if (er)
676
+ return this[ONERROR](er, entry)
677
+ this[CHECKED_CWD] = true
678
+ }
679
+
680
+ // don't bother to make the parent if the current entry is the cwd,
681
+ // we've already checked it.
682
+ if (entry.absolute !== this.cwd) {
683
+ const parent = normPath(path.dirname(entry.absolute))
684
+ if (parent !== this.cwd) {
685
+ const mkParent = this[MKDIR](parent, this.dmode)
686
+ if (mkParent)
687
+ return this[ONERROR](mkParent, entry)
501
688
  }
502
- } catch (er) {
689
+ }
690
+
691
+ const [lstatEr, st] = callSync(() => fs.lstatSync(entry.absolute))
692
+ if (st && (this.keep || this.newer && st.mtime > entry.mtime))
693
+ return this[SKIP](entry)
694
+
695
+ if (lstatEr || this[ISREUSABLE](entry, st))
503
696
  return this[MAKEFS](null, entry)
697
+
698
+ if (st.isDirectory()) {
699
+ if (entry.type === 'Directory') {
700
+ const needChmod = !this.noChmod &&
701
+ entry.mode &&
702
+ (st.mode & 0o7777) !== entry.mode
703
+ const [er] = needChmod ? callSync(() => {
704
+ fs.chmodSync(entry.absolute, entry.mode)
705
+ }) : []
706
+ return this[MAKEFS](er, entry)
707
+ }
708
+ // not a dir entry, have to remove it
709
+ const [er] = callSync(() => fs.rmdirSync(entry.absolute))
710
+ this[MAKEFS](er, entry)
504
711
  }
712
+
713
+ // not a dir, and not reusable.
714
+ // don't remove if it's the cwd, since we want that error.
715
+ const [er] = entry.absolute === this.cwd ? []
716
+ : callSync(() => unlinkFileSync(entry.absolute))
717
+ this[MAKEFS](er, entry)
505
718
  }
506
719
 
507
- [FILE] (entry) {
720
+ [FILE] (entry, done) {
508
721
  const mode = entry.mode & 0o7777 || this.fmode
509
722
 
510
723
  const oner = er => {
511
- try { fs.closeSync(fd) } catch (_) {}
512
- if (er)
513
- this[ONERROR](er, entry)
724
+ let closeError
725
+ try {
726
+ fs.closeSync(fd)
727
+ } catch (e) {
728
+ closeError = e
729
+ }
730
+ if (er || closeError)
731
+ this[ONERROR](er || closeError, entry)
732
+ done()
514
733
  }
515
734
 
516
735
  let stream
@@ -571,11 +790,14 @@ class UnpackSync extends Unpack {
571
790
  })
572
791
  }
573
792
 
574
- [DIRECTORY] (entry) {
793
+ [DIRECTORY] (entry, done) {
575
794
  const mode = entry.mode & 0o7777 || this.dmode
576
795
  const er = this[MKDIR](entry.absolute, mode)
577
- if (er)
578
- return this[ONERROR](er, entry)
796
+ if (er) {
797
+ this[ONERROR](er, entry)
798
+ done()
799
+ return
800
+ }
579
801
  if (entry.mtime && !this.noMtime) {
580
802
  try {
581
803
  fs.utimesSync(entry.absolute, entry.atime || new Date(), entry.mtime)
@@ -586,12 +808,13 @@ class UnpackSync extends Unpack {
586
808
  fs.chownSync(entry.absolute, this[UID](entry), this[GID](entry))
587
809
  } catch (er) {}
588
810
  }
811
+ done()
589
812
  entry.resume()
590
813
  }
591
814
 
592
815
  [MKDIR] (dir, mode) {
593
816
  try {
594
- return mkdir.sync(dir, {
817
+ return mkdir.sync(normPath(dir), {
595
818
  uid: this.uid,
596
819
  gid: this.gid,
597
820
  processUid: this.processUid,
@@ -608,9 +831,10 @@ class UnpackSync extends Unpack {
608
831
  }
609
832
  }
610
833
 
611
- [LINK] (entry, linkpath, link) {
834
+ [LINK] (entry, linkpath, link, done) {
612
835
  try {
613
836
  fs[link + 'Sync'](linkpath, entry.absolute)
837
+ done()
614
838
  entry.resume()
615
839
  } catch (er) {
616
840
  return this[ONERROR](er, entry)