浏览代码

Use TrustedFile before loading ISPP.dll.

Martijn Laan 5 月之前
父节点
当前提交
48357bb6fa
共有 3 个文件被更改,包括 6 次插入6 次删除
  1. 1 0
      Projects/ISCmplr.dpr
  2. 1 0
      Projects/ISCmplr.dproj
  3. 4 6
      Projects/Src/Compiler.SetupCompiler.pas

+ 1 - 0
Projects/ISCmplr.dpr

@@ -36,6 +36,7 @@ uses
   ChaCha20 in '..\Components\ChaCha20.pas',
   Shared.VerInfoFunc in 'Src\Shared.VerInfoFunc.pas',
   PathFunc in '..\Components\PathFunc.pas',
+  TrustFunc in '..\Components\TrustFunc.pas',
   Shared.CommonFunc in 'Src\Shared.CommonFunc.pas',
   Shared.Int64Em in 'Src\Shared.Int64Em.pas',
   SHA256 in '..\Components\SHA256.pas',

+ 1 - 0
Projects/ISCmplr.dproj

@@ -103,6 +103,7 @@
         <DCCReference Include="..\Components\ChaCha20.pas"/>
         <DCCReference Include="Src\Shared.VerInfoFunc.pas"/>
         <DCCReference Include="..\Components\PathFunc.pas"/>
+        <DCCReference Include="..\Components\TrustFunc.pas"/>
         <DCCReference Include="Src\Shared.CommonFunc.pas"/>
         <DCCReference Include="Src\Shared.Int64Em.pas"/>
         <DCCReference Include="..\Components\SHA256.pas"/>

+ 4 - 6
Projects/Src/Compiler.SetupCompiler.pas

@@ -291,7 +291,7 @@ implementation
 
 uses
   Commctrl, TypInfo, AnsiStrings, Math, WideStrUtils,
-  PathFunc, Shared.CommonFunc, Compiler.Messages, Shared.SetupEntFunc,
+  PathFunc, TrustFunc, Shared.CommonFunc, Compiler.Messages, Shared.SetupEntFunc,
   Shared.FileClass, Compression.Base, Compression.Zlib, Compression.bzlib,
   Shared.LangOptionsSectionDirectives, Shared.ResUpdateFunc, Compiler.ExeUpdateFunc,
 {$IFDEF STATICPREPROC}
@@ -518,10 +518,8 @@ begin
 {$IFNDEF STATICPREPROC}
   Filename := CompilerDir + 'ISPP.dll';
   Attr := GetFileAttributes(PChar(Filename));
-  if (Attr = $FFFFFFFF) and (GetLastError = ERROR_FILE_NOT_FOUND) then begin
-    { ISPP unavailable; fall back to built-in preprocessor }
-  end
-  else begin
+  if not ((Attr = $FFFFFFFF) and (GetLastError = ERROR_FILE_NOT_FOUND)) and
+     TrustedFile(Filename) then begin
     M := SafeLoadLibrary(Filename, SEM_NOOPENFILEERRORBOX);
     if M = 0 then
       AbortCompileFmt('Failed to load preprocessor DLL "%s" (%d)',
@@ -529,7 +527,7 @@ begin
     PreprocessScriptProc := GetProcAddress(M, 'ISPreprocessScriptW');
     if not Assigned(PreprocessScriptProc) then
       AbortCompileFmt('Failed to get address of functions in "%s"', [Filename]);
-  end;
+  end; { else ISPP unavailable; fall back to built-in preprocessor }
 {$ELSE}
   PreprocessScriptProc := ISPreprocessScript;
 {$ENDIF}