Procházet zdrojové kódy

Checking for too many parameters with /keygen switch

Source commit: f3321d8a489ebd25308f7153c14018b1490addb3
Martin Prikryl před 4 roky
rodič
revize
221679d554

+ 1 - 0
source/resource/TextsWin.h

@@ -90,6 +90,7 @@
 #define NO_SITE_FOR_COMMAND     1208
 #define DD_TARGET_UNKNOWN       1209
 #define JUMPLIST_ERROR          1210
+#define TOO_MANY_PARAMS_ERROR   1211
 
 #define WIN_CONFIRMATION_STRINGS 1300
 #define CONFIRM_OVERWRITE_SESSION 1301

+ 1 - 0
source/resource/TextsWin1.rc

@@ -98,6 +98,7 @@ BEGIN
         NO_SITE_FOR_COMMAND, "**No session is opened**\nThe selected command has site-specific options, but no session is opened."
         DD_TARGET_UNKNOWN, "**WinSCP was not able to detect a folder, where the dragged file(s) was dropped.** In the default drag&drop mode, WinSCP allows dropping files only to local drives and mapped network drives.\n\nYou can allow dropping files to other targets in preferences. Press Help button for details."
         JUMPLIST_ERROR, "Error updating jump list."
+        TOO_MANY_PARAMS_ERROR, "Too many parameters."
 
         WIN_CONFIRMATION_STRINGS, "WIN_CONFIRMATION"
         CONFIRM_OVERWRITE_SESSION, "Site with name '%s' already exists. Overwrite?"

+ 5 - 0
source/windows/ConsoleRunner.cpp

@@ -2567,6 +2567,11 @@ int __fastcall KeyGen(TConsole * Console, TProgramParams * Params)
     bool ChangePassphrase =
       FindPuttygenCompatibleSwitch(Params, KEYGEN_CHANGE_PASSPHRASE_SWITCH, L"P", NewPassphrase, NewPassphraseSet);
 
+    if (Params->ParamCount > 0)
+    {
+      throw Exception(LoadStr(TOO_MANY_PARAMS_ERROR));
+    }
+
     TKeyType Type = KeyType(InputFileName);
     int Error = errno;
     switch (Type)