enforce non-negative size in gzip parser

This commit is contained in:
Evan Wallace
2026-06-11 17:47:31 -04:00
parent 659fbb8376
commit 61299aaa40
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -130,7 +130,7 @@ function extractFileFromTarGzip(buffer: Uint8Array, file: string): Uint8Array {
let name = str(offset, 100)
let size = parseInt(str(offset + 124, 12), 8)
offset += 512
if (!isNaN(size)) {
if (!isNaN(size) && size >= 0) {
if (name === file) return buffer.subarray(offset, offset + size)
offset += (size + 511) & ~511
}
+1 -1
View File
@@ -94,7 +94,7 @@ function extractFileFromTarGzip(buffer: Buffer, subpath: string): Buffer {
let name = str(offset, 100)
let size = parseInt(str(offset + 124, 12), 8)
offset += 512
if (!isNaN(size)) {
if (!isNaN(size) && size >= 0) {
if (name === subpath) return buffer.subarray(offset, offset + size)
offset += (size + 511) & ~511
}