Преглед на файлове

- removed the repeated section bounds check in the section parsing code,
because now all reads go through the read function, which does section bounds
checking on every read

Nikolay Nikolov преди 1 година
родител
ревизия
b2861bacdd
променени са 1 файла, в които са добавени 0 реда и са изтрити 25 реда
  1. 0 25
      compiler/ogwasm.pas

+ 0 - 25
compiler/ogwasm.pas

@@ -2247,11 +2247,6 @@ implementation
                 InputError('Error reading the func types count');
                 exit;
               end;
-            if AReader.Pos>(SectionStart+SectionSize) then
-              begin
-                InputError('The func types count stretches beyond the end of the type section');
-                exit;
-              end;
             SetLength(FFuncTypes,FuncTypesCount);
             for i:=0 to FuncTypesCount - 1 do
               begin
@@ -2271,11 +2266,6 @@ implementation
                     InputError('Error reading the function parameters count');
                     exit;
                   end;
-                if AReader.Pos>(SectionStart+SectionSize) then
-                  begin
-                    InputError('The function paramaters count stretches beyond the end of the type section');
-                    exit;
-                  end;
                 for j:=0 to ParamsCount-1 do
                   begin
                     if not AReader.read(WasmTypeId,1) then
@@ -2295,11 +2285,6 @@ implementation
                     InputError('Error reading the function results count');
                     exit;
                   end;
-                if AReader.Pos>(SectionStart+SectionSize) then
-                  begin
-                    InputError('The function results count stretches beyond the end of the type section');
-                    exit;
-                  end;
                 for j:=0 to ResultsCount-1 do
                   begin
                     if not AReader.read(WasmTypeId,1) then
@@ -2345,11 +2330,6 @@ implementation
                 InputError('Error reading the imports count');
                 exit;
               end;
-            if AReader.Pos>(SectionStart+SectionSize) then
-              begin
-                InputError('The imports count stretches beyond the end of the import section');
-                exit;
-              end;
             for i:=0 to ImportsCount-1 do
               begin
                 if not ReadName(ModName) then
@@ -2539,11 +2519,6 @@ implementation
                 InputError('Error reading the functions count');
                 exit;
               end;
-            if AReader.Pos>(SectionStart+SectionSize) then
-              begin
-                InputError('The functions count stretches beyond the end of the function section');
-                exit;
-              end;
             for i:=0 to FunctionsCount-1 do
               begin
                 if not ReadUleb32(typidx) then