@vltpkg/tar 1.0.1 → 1.0.2

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.
Files changed (2) hide show
  1. package/dist/unpack.js +5 -5
  2. package/package.json +3 -3
package/dist/unpack.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { error } from '@vltpkg/error-cause';
2
2
  import { randomBytes } from 'node:crypto';
3
3
  import { lstat, mkdir, rename, writeFile } from 'node:fs/promises';
4
- import { basename, dirname, resolve, sep } from 'node:path';
4
+ import { basename, dirname, isAbsolute, relative, resolve, sep, } from 'node:path';
5
5
  import { rimraf } from 'rimraf';
6
6
  import { Header } from 'tar/header';
7
7
  import { Pax } from 'tar/pax';
@@ -33,10 +33,10 @@ const checkFs = (h, tarDir, target) => {
33
33
  // packages should always be in a 'package' tarDir in the archive
34
34
  if (!h.path.startsWith(tarDir))
35
35
  return false;
36
- // Package root
37
- const absoluteBasePath = target;
38
- const itemAbsolutePath = resolve(target, h.path.slice(tarDir.length));
39
- if (!itemAbsolutePath.startsWith(absoluteBasePath)) {
36
+ // entries must stay within the package root. separator-aware, so that
37
+ // a sibling dir whose name extends the target's is not a prefix match.
38
+ const rel = relative(target, resolve(target, h.path.slice(tarDir.length)));
39
+ if (rel === '..' || rel.startsWith(`..${sep}`) || isAbsolute(rel)) {
40
40
  return false;
41
41
  }
42
42
  return true;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vltpkg/tar",
3
3
  "description": "An extremely limited and very fast tar extractor",
4
- "version": "1.0.1",
4
+ "version": "1.0.2",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/vltpkg/vltpkg.git",
@@ -13,8 +13,8 @@
13
13
  "url": "http://vlt.sh"
14
14
  },
15
15
  "dependencies": {
16
- "@vltpkg/error-cause": "1.0.1",
17
- "@vltpkg/types": "1.0.1",
16
+ "@vltpkg/error-cause": "1.0.2",
17
+ "@vltpkg/types": "1.0.2",
18
18
  "rimraf": "^6.1.2",
19
19
  "tar": "^7.5.2"
20
20
  },