Martijn Laan před 2 měsíci
rodič
revize
23507b9d6c

+ 1 - 0
Projects/Src/Compiler.Messages.pas

@@ -90,6 +90,7 @@ const
   SCompilerVerificationSignatureMalformed = 'The signature file "%s" is malformed';
   SCompilerVerificationSignatureBad = 'The signature file "%s" is bad';
   SCompilerVerificationKeyNotFound = 'The signature file "%s" uses an unknown key';
+  SCompilerVerificationFileNameIncorrect = 'The name of the file is incorrect';
   SCompilerVerificationFileSizeIncorrect = 'The size of the file is incorrect';
   SCompilerVerificationFileHashIncorrect = 'The hash of the file is incorrect';
   SCompilerCopyError3a = 'Could not copy "%s" to "%s".' + SNewLine2 + 'Error %s';

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

@@ -6680,7 +6680,8 @@ const
   Messages: array[TVerificationError] of String =
     (SCompilerVerificationSignatureDoesntExist, SCompilerVerificationSignatureMalformed,
      SCompilerVerificationKeyNotFound, SCompilerVerificationSignatureBad,
-     SCompilerVerificationFileSizeIncorrect, SCompilerVerificationFileHashIncorrect);
+     SCompilerVerificationFileNameIncorrect, SCompilerVerificationFileSizeIncorrect,
+     SCompilerVerificationFileHashIncorrect);
 begin
   { Also see Setup.Install for a similar function }
   AbortCompileFmt(SCompilerSourceFileVerificationFailed,
@@ -7186,10 +7187,11 @@ var
             { See Setup.Install's CopySourceFileToDestFile for similar code }
             if Length(ISSigAvailableKeys) = 0 then { shouldn't fail: flag stripped already }
               AbortCompileFmt(SCompilerCompressInternalError, ['Length(ISSigAvailableKeys) = 0']);
+            var ExpectedFileName: String;
             var ExpectedFileSize: Int64;
             if not ISSigVerifySignature(FileLocationEntryFilenames[I],
               GetISSigAllowedKeys(ISSigAvailableKeys, FLExtraInfo.Verification.ISSigAllowedKeys),
-              ExpectedFileSize, ExpectedFileHash, FLExtraInfo.ISSigKeyUsedID,
+              ExpectedFileName, ExpectedFileSize, ExpectedFileHash, FLExtraInfo.ISSigKeyUsedID,
               nil,
               procedure(const Filename, SigFilename: String)
               begin
@@ -7208,6 +7210,8 @@ var
               end
             ) then
               AbortCompileFmt(SCompilerCompressInternalError, ['Unexpected ISSigVerifySignature result']);
+            if (ExpectedFileName <> '') and not PathSame(PathExtractName(FileLocationEntryFilenames[I]), ExpectedFileName) then
+              VerificationError(veFileNameIncorrect, FileLocationEntryFilenames[I]);
             if Int64(SourceFile.Size) <> ExpectedFileSize then
               VerificationError(veFileSizeIncorrect, FileLocationEntryFilenames[I]);
             { ExpectedFileHash checked below after compression }

+ 1 - 1
Projects/Src/Shared.SetupTypes.pas

@@ -40,7 +40,7 @@ type
   TArrayOfECDSAKey = array of TECDSAKey;
 
   TVerificationError = (veSignatureMissing, veSignatureMalformed, veKeyNotFound,
-    veSignatureBad, veFileSizeIncorrect, veFileHashIncorrect);
+    veSignatureBad, veFileNameIncorrect, veFileSizeIncorrect, veFileHashIncorrect);
 
 const
   crHand = 1;