Fix Uint8Array concat crash in Parse IPv4 header (#2409)

This commit is contained in:
Shivam Kumar 2026-06-15 14:04:25 +05:30 committed by GitHub
parent 3f62b14d83
commit 31808e83d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View File

@ -74,7 +74,7 @@ class ParseIPv4Header extends Operation {
checksum = input[10] << 8 | input[11],
srcIP = input[12] << 24 | input[13] << 16 | input[14] << 8 | input[15],
dstIP = input[16] << 24 | input[17] << 16 | input[18] << 8 | input[19],
checksumHeader = input.slice(0, 10).concat([0, 0]).concat(input.slice(12, 20));
checksumHeader = [...input.slice(0, 10), 0, 0, ...input.slice(12, 20)];
let version = (input[0] >>> 4) & 0x0f,
options = [];

View File

@ -19,5 +19,16 @@ TestRegister.addTests([
args: ["Hex", "Data (raw)"]
}
]
},
{
name: "Parse IPv4 header: regression for Uint8Array.concat crash on truncated raw input",
input: "\x45\x00\x00\x14\x00\x00\x00\x00\x40\x06\x00\x00",
expectedOutput: "",
recipeConfig: [
{
op: "Parse IPv4 header",
args: ["Raw", "Data (raw)"]
}
]
}
]);