-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch tar-stream to fix a race condition when installing snaps (#22602)
## **Description** `tar-stream` has a bug where it randomly fails to decode tar headers due to mixing of `Uint8Array` and polyfilled `Buffer`. I have upstreamed a fix for this, but while we wait for it to be released, this patch should fix the issue! Context on the bug: mafintosh/tar-stream#164
- Loading branch information
1 parent
d0695c6
commit 9740c82
Showing
3 changed files
with
38 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
diff --git a/headers.js b/headers.js | ||
index 56c3e9b26844d3e10a805cf850cdd09a172fa710..aa1a6c45d1623d9b94a5e065bd2872f0c4be4915 100644 | ||
--- a/headers.js | ||
+++ b/headers.js | ||
@@ -34,7 +34,7 @@ exports.decodePax = function decodePax (buf) { | ||
while (buf.length) { | ||
let i = 0 | ||
while (i < buf.length && buf[i] !== 32) i++ | ||
- const len = parseInt(buf.subarray(0, i).toString(), 10) | ||
+ const len = parseInt(b4a.toString(buf.subarray(0, i)), 10) | ||
if (!len) return result | ||
|
||
const b = b4a.toString(buf.subarray(i + 1, len - 1)) | ||
@@ -304,7 +304,7 @@ function decodeOct (val, offset, length) { | ||
const end = clamp(indexOf(val, 32, offset, val.length), val.length, val.length) | ||
while (offset < end && val[offset] === 0) offset++ | ||
if (end === offset) return 0 | ||
- return parseInt(val.subarray(offset, end).toString(), 8) | ||
+ return parseInt(b4a.toString(val.subarray(offset, end)), 8) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters