Bläddra i källkod

Be more friendly.

Martijn Laan 1 månad sedan
förälder
incheckning
f724a43d70

+ 4 - 6
Projects/SetupLdr.dpr

@@ -419,12 +419,10 @@ begin
       var CryptKey: TSetupEncryptionKey;
       var CryptKey: TSetupEncryptionKey;
       if SetupEncryptionHeader.EncryptionUse = euFull then begin
       if SetupEncryptionHeader.EncryptionUse = euFull then begin
         var PasswordOk: Boolean;
         var PasswordOk: Boolean;
-        if InitPassword <> '' then begin
-          GenerateEncryptionKey(InitPassword, SetupEncryptionHeader.EncryptionKDFSalt, SetupEncryptionHeader.EncryptionKDFIterations, CryptKey);
-          PasswordOk := TestPassword(CryptKey, SetupEncryptionHeader.EncryptionBaseNonce, SetupEncryptionHeader.PasswordTest);
-        end else
-          PasswordOk := False;
-        if not PasswordOk then
+        if InitPassword = '' then
+          raise Exception.Create(SMissingPassword);
+        GenerateEncryptionKey(InitPassword, SetupEncryptionHeader.EncryptionKDFSalt, SetupEncryptionHeader.EncryptionKDFIterations, CryptKey);
+        if not TestPassword(CryptKey, SetupEncryptionHeader.EncryptionBaseNonce, SetupEncryptionHeader.PasswordTest) then
           raise Exception.Create(SIncorrectPassword);
           raise Exception.Create(SIncorrectPassword);
       end;
       end;
 
 

+ 2 - 0
Projects/Src/Setup.MainFunc.pas

@@ -3105,6 +3105,8 @@ begin
 
 
     var CryptKey: TSetupEncryptionKey;
     var CryptKey: TSetupEncryptionKey;
     if SetupEncryptionHeader.EncryptionUse = euFull then begin
     if SetupEncryptionHeader.EncryptionUse = euFull then begin
+      if InitPassword = '' then
+        raise Exception.Create(SMissingPassword);
       { HandleInitPassword requires this }
       { HandleInitPassword requires this }
       SetupHeader.Options := SetupHeader.Options + [shPassword];
       SetupHeader.Options := SetupHeader.Options + [shPassword];
       { Specifying False for AllowSetFileExtractorCryptKey because FileExtractor (a function!)
       { Specifying False for AllowSetFileExtractorCryptKey because FileExtractor (a function!)

+ 2 - 1
Projects/Src/SetupLdrAndSetup.Messages.pas

@@ -47,7 +47,8 @@ const
     'obtain a new copy of the program.';
     'obtain a new copy of the program.';
   SMsgsFileMissing = 'Messages file "%s" is missing. Please correct ' +
   SMsgsFileMissing = 'Messages file "%s" is missing. Please correct ' +
     'the problem or obtain a new copy of the program.';
     'the problem or obtain a new copy of the program.';
-  SIncorrectPassword = 'The password you entered is not correct. Please try again.';
+  SMissingPassword = 'Please specify the password using the /PASSWORD= command line parameter.';
+  SIncorrectPassword = 'The password you specified is not correct. Please try again.';
 
 
 implementation
 implementation