Procházet zdrojové kódy

Bug fix: Running WinSCP for a maintenance task unintentionally creates a random seed file

Source commit: 6afce2ecb72b08fc9e576b5f5c28bb93b23c59e1
Martin Prikryl před 6 roky
rodič
revize
63341b43de
1 změnil soubory, kde provedl 7 přidání a 0 odebrání
  1. 7 0
      source/core/PuttyIntf.cpp

+ 7 - 0
source/core/PuttyIntf.cpp

@@ -17,6 +17,7 @@ extern const char commitid[] = "";
 const bool platform_uses_x11_unix_by_default = true;
 const bool platform_uses_x11_unix_by_default = true;
 CRITICAL_SECTION putty_section;
 CRITICAL_SECTION putty_section;
 bool SaveRandomSeed;
 bool SaveRandomSeed;
+bool HadRandomSeed;
 char appname_[50];
 char appname_[50];
 const char *const appname = appname_;
 const char *const appname = appname_;
 extern const bool share_can_be_downstream = false;
 extern const bool share_can_be_downstream = false;
@@ -38,6 +39,7 @@ void __fastcall PuttyInitialize()
 
 
   InitializeCriticalSection(&putty_section);
   InitializeCriticalSection(&putty_section);
 
 
+  HadRandomSeed = FileExists(ApiPath(Configuration->RandomSeedFileName));
   // make sure random generator is initialised, so random_save_seed()
   // make sure random generator is initialised, so random_save_seed()
   // in destructor can proceed
   // in destructor can proceed
   random_ref();
   random_ref();
@@ -61,6 +63,11 @@ void __fastcall PuttyFinalize()
     random_save_seed();
     random_save_seed();
   }
   }
   random_unref();
   random_unref();
+  // random_ref in PuttyInitialize creates the seed file. Delete it, if didn't want to create it.
+  if (!HadRandomSeed && !SaveRandomSeed)
+  {
+    DeleteFile(ApiPath(Configuration->RandomSeedFileName));
+  }
 
 
   sk_cleanup();
   sk_cleanup();
   win_misc_cleanup();
   win_misc_cleanup();