diff --git a/src/core/operations/ParseIPv4Header.mjs b/src/core/operations/ParseIPv4Header.mjs index a1ab93b3..65a8b63f 100644 --- a/src/core/operations/ParseIPv4Header.mjs +++ b/src/core/operations/ParseIPv4Header.mjs @@ -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 = []; diff --git a/tests/operations/tests/ParseIPv4Header.mjs b/tests/operations/tests/ParseIPv4Header.mjs index 47c2592a..ddebe3b9 100644 --- a/tests/operations/tests/ParseIPv4Header.mjs +++ b/tests/operations/tests/ParseIPv4Header.mjs @@ -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)"] + } + ] } ]);