|
@@ -2202,7 +2202,7 @@ implementation
|
|
function ReadSection: Boolean;
|
|
function ReadSection: Boolean;
|
|
var
|
|
var
|
|
SectionId: Byte;
|
|
SectionId: Byte;
|
|
- SectionSize: uint64;
|
|
|
|
|
|
+ SectionSize: uint32;
|
|
SectionStart: LongInt;
|
|
SectionStart: LongInt;
|
|
|
|
|
|
TypeSectionRead: Boolean = false;
|
|
TypeSectionRead: Boolean = false;
|
|
@@ -2315,7 +2315,7 @@ implementation
|
|
function ReadImportSection: Boolean;
|
|
function ReadImportSection: Boolean;
|
|
var
|
|
var
|
|
ImportsCount, typidx, TableLimitsMin, TableLimitsMax,
|
|
ImportsCount, typidx, TableLimitsMin, TableLimitsMax,
|
|
- MemoryLimitsMin, MemoryLimitsMax: uint64;
|
|
|
|
|
|
+ MemoryLimitsMin, MemoryLimitsMax: uint32;
|
|
i: Integer;
|
|
i: Integer;
|
|
ModName, Name: ansistring;
|
|
ModName, Name: ansistring;
|
|
ImportType, TableElemTyp, TableLimitsKind, MemoryLimitsKind,
|
|
ImportType, TableElemTyp, TableLimitsKind, MemoryLimitsKind,
|
|
@@ -2329,7 +2329,7 @@ implementation
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
ImportSectionRead:=True;
|
|
ImportSectionRead:=True;
|
|
- if not ReadUleb(AReader,ImportsCount) then
|
|
|
|
|
|
+ if not ReadUleb32(AReader,ImportsCount) then
|
|
begin
|
|
begin
|
|
InputError('Error reading the imports count');
|
|
InputError('Error reading the imports count');
|
|
exit;
|
|
exit;
|
|
@@ -2339,11 +2339,6 @@ implementation
|
|
InputError('The imports count stretches beyond the end of the import section');
|
|
InputError('The imports count stretches beyond the end of the import section');
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
- if ImportsCount>high(uint32) then
|
|
|
|
- begin
|
|
|
|
- InputError('The imports count does not fit in an unsigned 32-bit int');
|
|
|
|
- exit;
|
|
|
|
- end;
|
|
|
|
for i:=0 to ImportsCount-1 do
|
|
for i:=0 to ImportsCount-1 do
|
|
begin
|
|
begin
|
|
if not ReadName(AReader,ModName) then
|
|
if not ReadName(AReader,ModName) then
|
|
@@ -2364,7 +2359,7 @@ implementation
|
|
case ImportType of
|
|
case ImportType of
|
|
$00: { func }
|
|
$00: { func }
|
|
begin
|
|
begin
|
|
- if not ReadUleb(AReader,typidx) then
|
|
|
|
|
|
+ if not ReadUleb32(AReader,typidx) then
|
|
begin
|
|
begin
|
|
InputError('Error reading type index for func import');
|
|
InputError('Error reading type index for func import');
|
|
exit;
|
|
exit;
|
|
@@ -2400,39 +2395,24 @@ implementation
|
|
case TableLimitsKind of
|
|
case TableLimitsKind of
|
|
$00:
|
|
$00:
|
|
begin
|
|
begin
|
|
- if not ReadUleb(AReader,TableLimitsMin) then
|
|
|
|
|
|
+ if not ReadUleb32(AReader,TableLimitsMin) then
|
|
begin
|
|
begin
|
|
InputError('Error reading table limits min for table import');
|
|
InputError('Error reading table limits min for table import');
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
- if TableLimitsMin>high(uint32) then
|
|
|
|
- begin
|
|
|
|
- InputError('Table limits min does not fit in an unsigned 32-bit int');
|
|
|
|
- exit;
|
|
|
|
- end;
|
|
|
|
end;
|
|
end;
|
|
$01:
|
|
$01:
|
|
begin
|
|
begin
|
|
- if not ReadUleb(AReader,TableLimitsMin) then
|
|
|
|
|
|
+ if not ReadUleb32(AReader,TableLimitsMin) then
|
|
begin
|
|
begin
|
|
InputError('Error reading table limits min for table import');
|
|
InputError('Error reading table limits min for table import');
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
- if TableLimitsMin>high(uint32) then
|
|
|
|
- begin
|
|
|
|
- InputError('Table limits min does not fit in an unsigned 32-bit int');
|
|
|
|
- exit;
|
|
|
|
- end;
|
|
|
|
- if not ReadUleb(AReader,TableLimitsMax) then
|
|
|
|
|
|
+ if not ReadUleb32(AReader,TableLimitsMax) then
|
|
begin
|
|
begin
|
|
InputError('Error reading table limits max for table import');
|
|
InputError('Error reading table limits max for table import');
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
- if TableLimitsMax>high(uint32) then
|
|
|
|
- begin
|
|
|
|
- InputError('Table limits max does not fit in an unsigned 32-bit int');
|
|
|
|
- exit;
|
|
|
|
- end;
|
|
|
|
if TableLimitsMin>TableLimitsMax then
|
|
if TableLimitsMin>TableLimitsMax then
|
|
begin
|
|
begin
|
|
InputError('Table limits min exceed table limits max in table import');
|
|
InputError('Table limits min exceed table limits max in table import');
|
|
@@ -2456,39 +2436,24 @@ implementation
|
|
case MemoryLimitsKind of
|
|
case MemoryLimitsKind of
|
|
$00:
|
|
$00:
|
|
begin
|
|
begin
|
|
- if not ReadUleb(AReader,MemoryLimitsMin) then
|
|
|
|
|
|
+ if not ReadUleb32(AReader,MemoryLimitsMin) then
|
|
begin
|
|
begin
|
|
InputError('Error reading memory limits min for memory import');
|
|
InputError('Error reading memory limits min for memory import');
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
- if MemoryLimitsMin>high(uint32) then
|
|
|
|
- begin
|
|
|
|
- InputError('Memory limits min does not fit in an unsigned 32-bit int');
|
|
|
|
- exit;
|
|
|
|
- end;
|
|
|
|
end;
|
|
end;
|
|
$01:
|
|
$01:
|
|
begin
|
|
begin
|
|
- if not ReadUleb(AReader,MemoryLimitsMin) then
|
|
|
|
|
|
+ if not ReadUleb32(AReader,MemoryLimitsMin) then
|
|
begin
|
|
begin
|
|
InputError('Error reading memory limits min for memory import');
|
|
InputError('Error reading memory limits min for memory import');
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
- if MemoryLimitsMin>high(uint32) then
|
|
|
|
- begin
|
|
|
|
- InputError('Memory limits min does not fit in an unsigned 32-bit int');
|
|
|
|
- exit;
|
|
|
|
- end;
|
|
|
|
- if not ReadUleb(AReader,MemoryLimitsMax) then
|
|
|
|
|
|
+ if not ReadUleb32(AReader,MemoryLimitsMax) then
|
|
begin
|
|
begin
|
|
InputError('Error reading memory limits max for memory import');
|
|
InputError('Error reading memory limits max for memory import');
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
- if MemoryLimitsMax>high(uint32) then
|
|
|
|
- begin
|
|
|
|
- InputError('Memory limits max does not fit in an unsigned 32-bit int');
|
|
|
|
- exit;
|
|
|
|
- end;
|
|
|
|
if MemoryLimitsMin>MemoryLimitsMax then
|
|
if MemoryLimitsMin>MemoryLimitsMax then
|
|
begin
|
|
begin
|
|
InputError('Memory limits min exceed memory limits max in memory import');
|
|
InputError('Memory limits min exceed memory limits max in memory import');
|
|
@@ -2548,7 +2513,7 @@ implementation
|
|
|
|
|
|
function ReadFunctionSection: Boolean;
|
|
function ReadFunctionSection: Boolean;
|
|
var
|
|
var
|
|
- FunctionsCount, typidx: uint64;
|
|
|
|
|
|
+ FunctionsCount, typidx: uint32;
|
|
i: Integer;
|
|
i: Integer;
|
|
begin
|
|
begin
|
|
Result:=False;
|
|
Result:=False;
|
|
@@ -2558,7 +2523,7 @@ implementation
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
FunctionSectionRead:=True;
|
|
FunctionSectionRead:=True;
|
|
- if not ReadUleb(AReader,FunctionsCount) then
|
|
|
|
|
|
+ if not ReadUleb32(AReader,FunctionsCount) then
|
|
begin
|
|
begin
|
|
InputError('Error reading the functions count');
|
|
InputError('Error reading the functions count');
|
|
exit;
|
|
exit;
|
|
@@ -2568,14 +2533,9 @@ implementation
|
|
InputError('The functions count stretches beyond the end of the function section');
|
|
InputError('The functions count stretches beyond the end of the function section');
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
- if FunctionsCount>high(uint32) then
|
|
|
|
- begin
|
|
|
|
- InputError('The functions count does not fit in an unsigned 32-bit int');
|
|
|
|
- exit;
|
|
|
|
- end;
|
|
|
|
for i:=0 to FunctionsCount-1 do
|
|
for i:=0 to FunctionsCount-1 do
|
|
begin
|
|
begin
|
|
- if not ReadUleb(AReader,typidx) then
|
|
|
|
|
|
+ if not ReadUleb32(AReader,typidx) then
|
|
begin
|
|
begin
|
|
InputError('Error reading type index for function');
|
|
InputError('Error reading type index for function');
|
|
exit;
|
|
exit;
|
|
@@ -2616,7 +2576,7 @@ implementation
|
|
|
|
|
|
function ReadDataCountSection: Boolean;
|
|
function ReadDataCountSection: Boolean;
|
|
var
|
|
var
|
|
- v: uint64;
|
|
|
|
|
|
+ v: uint32;
|
|
begin
|
|
begin
|
|
Result:=False;
|
|
Result:=False;
|
|
if DataCountSectionRead then
|
|
if DataCountSectionRead then
|
|
@@ -2625,16 +2585,11 @@ implementation
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
DataCountSectionRead:=True;
|
|
DataCountSectionRead:=True;
|
|
- if not ReadUleb(AReader,v) then
|
|
|
|
|
|
+ if not ReadUleb32(AReader,v) then
|
|
begin
|
|
begin
|
|
InputError('Error reading the data count from the data count section');
|
|
InputError('Error reading the data count from the data count section');
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
- if v>high(uint32) then
|
|
|
|
- begin
|
|
|
|
- InputError('Data count does not fit in an unsigned 32-bit int');
|
|
|
|
- exit;
|
|
|
|
- end;
|
|
|
|
DataCount:=v;
|
|
DataCount:=v;
|
|
if AReader.Pos<>(SectionStart+SectionSize) then
|
|
if AReader.Pos<>(SectionStart+SectionSize) then
|
|
begin
|
|
begin
|
|
@@ -2651,16 +2606,11 @@ implementation
|
|
InputError('Error reading section ID');
|
|
InputError('Error reading section ID');
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
- if not ReadUleb(AReader,SectionSize) then
|
|
|
|
|
|
+ if not ReadUleb32(AReader,SectionSize) then
|
|
begin
|
|
begin
|
|
InputError('Error reading section size');
|
|
InputError('Error reading section size');
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
- if SectionSize>high(uint32) then
|
|
|
|
- begin
|
|
|
|
- InputError('Invalid section size');
|
|
|
|
- exit;
|
|
|
|
- end;
|
|
|
|
if (AReader.Pos+SectionSize)>AReader.size then
|
|
if (AReader.Pos+SectionSize)>AReader.size then
|
|
begin
|
|
begin
|
|
InputError('Section exceeds beyond the end of file');
|
|
InputError('Section exceeds beyond the end of file');
|