+ wasm internal object reader: added range check to the reader of the SymKind field

This commit is contained in:
Nikolay Nikolov 2024-01-06 20:54:04 +02:00
parent f3401c3f53
commit b35c118244

View File

@ -2752,6 +2752,7 @@ implementation
SymCount: uint32;
i: Integer;
SymKindName: string;
SymKindB: Byte;
begin
Result:=False;
if SymbolTableSectionRead then
@ -2769,11 +2770,17 @@ implementation
for i:=0 to SymCount-1 do
with SymbolTable[i] do
begin
if not Read(SymKind,1) then
if not Read(SymKindB,1) then
begin
InputError('Error reading symbol type from the WASM_SYMBOL_TABLE subsection of the ''linking'' section');
exit;
end;
if (SymKindB<Low(Ord(TWasmSymbolType))) or (SymKindB>High(Ord(TWasmSymbolType))) then
begin
InputError('Unsupported symbol type from the WASM_SYMBOL_TABLE subsection of the ''linking'' section');
exit;
end;
SymKind:=TWasmSymbolType(SymKindB);
if not ReadUleb32(SymFlags) then
begin
InputError('Error reading symbol flags from the WASM_SYMBOL_TABLE subsection of the ''linking'' section');