瀏覽代碼

+ parse and check the version of the 'linking' section

Nikolay Nikolov 1 年之前
父節點
當前提交
8802c7d489
共有 1 個文件被更改,包括 14 次插入0 次删除
  1. 14 0
      compiler/ogwasm.pas

+ 14 - 0
compiler/ogwasm.pas

@@ -2232,8 +2232,22 @@ implementation
             end;
             end;
 
 
           function ReadLinkingSection: Boolean;
           function ReadLinkingSection: Boolean;
+            const
+              ExpectedVersion = 2;
+            var
+              Version: uint32;
             begin
             begin
               Result:=False;
               Result:=False;
+              if not ReadUleb32(Version) then
+                begin
+                  InputError('Error reading the version of the ''linking'' subsection');
+                  exit;
+                end;
+              if Version<>ExpectedVersion then
+                begin
+                  InputError('The ''linking'' subsection has an unsupported version (expected version ' + tostr(ExpectedVersion) + ', got version ' + tostr(Version) + ')');
+                  exit;
+                end;
             end;
             end;
 
 
           function ReadProducersSection: Boolean;
           function ReadProducersSection: Boolean;