mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-30 15:00:16 +02:00
+ verify the segment count when parsing the WASM_SEGMENT_INFO subsection
* moved local vars to avoid bug
This commit is contained in:
parent
bbb564437d
commit
e754937ad3
@ -2149,12 +2149,28 @@ implementation
|
|||||||
|
|
||||||
function TWasmObjInput.ReadObjData(AReader: TObjectreader; out ObjData: TObjData): boolean;
|
function TWasmObjInput.ReadObjData(AReader: TObjectreader; out ObjData: TObjData): boolean;
|
||||||
|
|
||||||
|
var
|
||||||
|
SectionId: Byte;
|
||||||
|
SectionSize: uint32;
|
||||||
|
SectionStart: LongInt;
|
||||||
|
CheckSectionBounds: Boolean;
|
||||||
|
|
||||||
|
TypeSectionRead: Boolean = false;
|
||||||
|
ImportSectionRead: Boolean = false;
|
||||||
|
FunctionSectionRead: Boolean = false;
|
||||||
|
CodeSectionRead: Boolean = false;
|
||||||
|
DataSectionRead: Boolean = false;
|
||||||
|
DataCountSectionRead: Boolean = false;
|
||||||
|
|
||||||
|
DataSegments: array of record
|
||||||
|
Active: Boolean;
|
||||||
|
MemIdx: uint32;
|
||||||
|
Len: uint32;
|
||||||
|
Offset: int32;
|
||||||
|
DataPos: LongInt;
|
||||||
|
end;
|
||||||
|
|
||||||
function ReadSection: Boolean;
|
function ReadSection: Boolean;
|
||||||
var
|
|
||||||
SectionId: Byte;
|
|
||||||
SectionSize: uint32;
|
|
||||||
SectionStart: LongInt;
|
|
||||||
CheckSectionBounds: Boolean;
|
|
||||||
|
|
||||||
function read(out b;len:longint):boolean;
|
function read(out b;len:longint):boolean;
|
||||||
begin
|
begin
|
||||||
@ -2265,22 +2281,6 @@ implementation
|
|||||||
result:=true;
|
result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
|
||||||
TypeSectionRead: Boolean = false;
|
|
||||||
ImportSectionRead: Boolean = false;
|
|
||||||
FunctionSectionRead: Boolean = false;
|
|
||||||
CodeSectionRead: Boolean = false;
|
|
||||||
DataSectionRead: Boolean = false;
|
|
||||||
DataCountSectionRead: Boolean = false;
|
|
||||||
|
|
||||||
DataSegments: array of record
|
|
||||||
Active: Boolean;
|
|
||||||
MemIdx: uint32;
|
|
||||||
Len: uint32;
|
|
||||||
Offset: int32;
|
|
||||||
DataPos: LongInt;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function ReadCustomSection: Boolean;
|
function ReadCustomSection: Boolean;
|
||||||
|
|
||||||
function ReadRelocationSection: Boolean;
|
function ReadRelocationSection: Boolean;
|
||||||
@ -2311,6 +2311,11 @@ implementation
|
|||||||
InputError('Error reading the segment count from the WASM_SEGMENT_INFO subsection of the ''linking'' section');
|
InputError('Error reading the segment count from the WASM_SEGMENT_INFO subsection of the ''linking'' section');
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
if SegmentCount<>Length(DataSegments) then
|
||||||
|
begin
|
||||||
|
InputError('Segment count in the WASM_SEGMENT_INFO subsection does not match the data count in the data section');
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
for i:=0 to SegmentCount-1 do
|
for i:=0 to SegmentCount-1 do
|
||||||
begin
|
begin
|
||||||
if not ReadName(SegName) then
|
if not ReadName(SegName) then
|
||||||
|
Loading…
Reference in New Issue
Block a user