From b86450929796950a1fe4b1f9b02b1634c812f3bb Mon Sep 17 00:00:00 2001 From: isaacs Date: Mon, 1 Jul 2019 22:16:42 -0700 Subject: [PATCH] tar-stream@2.1.0 --- node_modules/tar-stream/headers.js | 30 +++++++++++++++++++++------- node_modules/tar-stream/package.json | 22 ++++++++++---------- package-lock.json | 6 +++--- package.json | 2 +- 4 files changed, 38 insertions(+), 22 deletions(-) diff --git a/node_modules/tar-stream/headers.js b/node_modules/tar-stream/headers.js index 8571c8739d791..fe7fd36735c8d 100644 --- a/node_modules/tar-stream/headers.js +++ b/node_modules/tar-stream/headers.js @@ -3,8 +3,13 @@ var alloc = Buffer.alloc var ZEROS = '0000000000000000000' var SEVENS = '7777777777777777777' var ZERO_OFFSET = '0'.charCodeAt(0) -var USTAR = 'ustar\x0000' +var USTAR_MAGIC = Buffer.from('ustar\x00', 'binary') +var USTAR_VER = Buffer.from('00', 'binary') +var GNU_MAGIC = Buffer.from('ustar\x20', 'binary') +var GNU_VER = Buffer.from('\x20\x00', 'binary') var MASK = parseInt('7777', 8) +var MAGIC_OFFSET = 257 +var VERSION_OFFSET = 263 var clamp = function (index, len, defaultValue) { if (typeof index !== 'number') return defaultValue @@ -223,7 +228,8 @@ exports.encode = function (opts) { if (opts.linkname) buf.write(opts.linkname, 157) - buf.write(USTAR, 257) + USTAR_MAGIC.copy(buf, MAGIC_OFFSET) + USTAR_VER.copy(buf, VERSION_OFFSET) if (opts.uname) buf.write(opts.uname, 265) if (opts.gname) buf.write(opts.gname, 297) buf.write(encodeOct(opts.devmajor || 0, 6), 329) @@ -252,11 +258,6 @@ exports.decode = function (buf, filenameEncoding) { var devmajor = decodeOct(buf, 329, 8) var devminor = decodeOct(buf, 337, 8) - if (buf[345]) name = decodeStr(buf, 345, 155, filenameEncoding) + '/' + name - - // to support old tar versions that use trailing / to indicate dirs - if (typeflag === 0 && name && name[name.length - 1] === '/') typeflag = 5 - var c = cksum(buf) // checksum is still initial value if header was null. @@ -265,6 +266,21 @@ exports.decode = function (buf, filenameEncoding) { // valid checksum if (c !== decodeOct(buf, 148, 8)) throw new Error('Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped?') + if (USTAR_MAGIC.compare(buf, MAGIC_OFFSET, MAGIC_OFFSET + 6) === 0) { + // ustar (posix) format. + // prepend prefix, if present. + if (buf[345]) name = decodeStr(buf, 345, 155, filenameEncoding) + '/' + name + } else if (GNU_MAGIC.compare(buf, MAGIC_OFFSET, MAGIC_OFFSET + 6) === 0 && + GNU_VER.compare(buf, VERSION_OFFSET, VERSION_OFFSET + 2) === 0) { + // 'gnu'/'oldgnu' format. Similar to ustar, but has support for incremental and + // multi-volume tarballs. + } else { + throw new Error('Invalid tar header: unknown format.') + } + + // to support old tar versions that use trailing / to indicate dirs + if (typeflag === 0 && name && name[name.length - 1] === '/') typeflag = 5 + return { name: name, mode: mode, diff --git a/node_modules/tar-stream/package.json b/node_modules/tar-stream/package.json index 9ec13dca1f28a..9acb919dca310 100644 --- a/node_modules/tar-stream/package.json +++ b/node_modules/tar-stream/package.json @@ -1,28 +1,28 @@ { - "_from": "tar-stream@2.0.1", - "_id": "tar-stream@2.0.1", + "_from": "tar-stream@2.1.0", + "_id": "tar-stream@2.1.0", "_inBundle": false, - "_integrity": "sha512-I6OJF7wE62BC6zNPdHDtseK0D0187PBjbKSLYY4ffvVkBM6tyBn2O9plDvVM2229/mozfEL/X3++qSvYYQE2xw==", + "_integrity": "sha512-+DAn4Nb4+gz6WZigRzKEZl1QuJVOLtAwwF+WUxy1fJ6X63CaGaUAxJRD2KEn1OMfcbCjySTYpNC6WmfQoIEOdw==", "_location": "/tar-stream", "_phantomChildren": {}, "_requested": { "type": "version", "registry": true, - "raw": "tar-stream@2.0.1", + "raw": "tar-stream@2.1.0", "name": "tar-stream", "escapedName": "tar-stream", - "rawSpec": "2.0.1", + "rawSpec": "2.1.0", "saveSpec": null, - "fetchSpec": "2.0.1" + "fetchSpec": "2.1.0" }, "_requiredBy": [ "#DEV:/", "#USER" ], - "_resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.0.1.tgz", - "_shasum": "42fbe41cd1cc5e6657c813e7d98e7afca2858a8c", - "_spec": "tar-stream@2.0.1", - "_where": "/Users/aeschright/code/cli", + "_resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.1.0.tgz", + "_shasum": "d1aaa3661f05b38b5acc9b7020efdca5179a2cc3", + "_spec": "tar-stream@2.1.0", + "_where": "/Users/isaacs/dev/npm/cli", "author": { "name": "Mathias Buus", "email": "mathiasbuus@gmail.com" @@ -80,5 +80,5 @@ "test": "standard && tape test/extract.js test/pack.js", "test-all": "standard && tape test/*.js" }, - "version": "2.0.1" + "version": "2.1.0" } diff --git a/package-lock.json b/package-lock.json index d3b31a51178c7..386ad3df4f078 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5901,9 +5901,9 @@ } }, "tar-stream": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.0.1.tgz", - "integrity": "sha512-I6OJF7wE62BC6zNPdHDtseK0D0187PBjbKSLYY4ffvVkBM6tyBn2O9plDvVM2229/mozfEL/X3++qSvYYQE2xw==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.1.0.tgz", + "integrity": "sha512-+DAn4Nb4+gz6WZigRzKEZl1QuJVOLtAwwF+WUxy1fJ6X63CaGaUAxJRD2KEn1OMfcbCjySTYpNC6WmfQoIEOdw==", "dev": true, "requires": { "bl": "^3.0.0", diff --git a/package.json b/package.json index dfae7acbf83fa..3e46b1b1e4aa1 100644 --- a/package.json +++ b/package.json @@ -281,7 +281,7 @@ "standard": "^11.0.1", "tacks": "^1.3.0", "tap": "^12.7.0", - "tar-stream": "^2.0.1" + "tar-stream": "^2.1.0" }, "scripts": { "dumpconf": "env | grep npm | sort | uniq",