mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 13:12:26 +00:00
* fix(elf): reject invalid section table and zlib declarations Refs #10149, #10148, #9330. Co-authored-by: Nianze Wu <wunianze666@gmail.com> * fix(elf): share section count admission with carrier readers (#12196) fix(elf): admit section tables before carrier recognition --------- Co-authored-by: Nianze Wu <wunianze666@gmail.com>
24 lines
716 B
TypeScript
24 lines
716 B
TypeScript
/** Parse Node's info:true codec result, absent from the pinned @types/node overloads. */
|
|
export const nodeCodecResult = (
|
|
value: unknown,
|
|
): {
|
|
readonly buffer: Buffer;
|
|
readonly consumedBytes: number;
|
|
} => {
|
|
if (
|
|
typeof value !== "object" ||
|
|
value === null ||
|
|
!("buffer" in value) ||
|
|
!Buffer.isBuffer(value.buffer) ||
|
|
!("engine" in value) ||
|
|
typeof value.engine !== "object" ||
|
|
value.engine === null ||
|
|
!("bytesWritten" in value.engine) ||
|
|
typeof value.engine.bytesWritten !== "number"
|
|
)
|
|
throw new Error(
|
|
"Built-in decoder omitted its buffer or consumed-input accounting",
|
|
);
|
|
return { buffer: value.buffer, consumedBytes: value.engine.bytesWritten };
|
|
};
|