Browse Source

Bug fix: When only encrypted session setting (like passwords) were changed during mass-modification, changes were not saved

Source commit: dfb936c29e406acaa813044580f0151c1e4abf8d
Martin Prikryl 6 years ago
parent
commit
64141068d7
2 changed files with 14 additions and 7 deletions
  1. 14 4
      source/core/SessionData.cpp
  2. 0 3
      source/core/SessionData.h

+ 14 - 4
source/core/SessionData.cpp

@@ -21,6 +21,12 @@
 //---------------------------------------------------------------------------
 #pragma package(smart_init)
 //---------------------------------------------------------------------------
+#define SET_SESSION_PROPERTY_FROM(PROPERTY, FROM) \
+  if (F##PROPERTY != FROM) { F##PROPERTY = FROM; Modify(); }
+//---------------------------------------------------------------------------
+#define SET_SESSION_PROPERTY(PROPERTY) \
+  SET_SESSION_PROPERTY_FROM(PROPERTY, value)
+//---------------------------------------------------------------------------
 const wchar_t * PingTypeNames = L"Off;Null;Dummy";
 const wchar_t * ProxyMethodNames = L"None;SOCKS4;SOCKS5;HTTP;Telnet;Cmd";
 const wchar_t * DefaultName = L"Default Settings";
@@ -565,7 +571,8 @@ void __fastcall TSessionData::DoLoad(THierarchicalStorage * Storage, bool PuttyI
     }
     else
     {
-      FPassword = Storage->ReadStringAsBinaryData(L"Password", FPassword);
+      RawByteString APassword = Storage->ReadStringAsBinaryData(L"Password", FPassword);
+      SET_SESSION_PROPERTY_FROM(Password, APassword);
     }
   }
   HostKey = Storage->ReadString(L"SshHostKey", HostKey); // probably never used
@@ -684,7 +691,8 @@ void __fastcall TSessionData::DoLoad(THierarchicalStorage * Storage, bool PuttyI
   else
   {
     // load encrypted password
-    FProxyPassword = Storage->ReadStringAsBinaryData(L"ProxyPasswordEnc", FProxyPassword);
+    RawByteString AProxyPassword = Storage->ReadStringAsBinaryData(L"ProxyPasswordEnc", FProxyPassword);
+    SET_SESSION_PROPERTY_FROM(ProxyPassword, AProxyPassword);
   }
   if (ProxyMethod == pmCmd)
   {
@@ -753,7 +761,8 @@ void __fastcall TSessionData::DoLoad(THierarchicalStorage * Storage, bool PuttyI
     }
     else
     {
-      FTunnelPassword = Storage->ReadStringAsBinaryData(L"TunnelPassword", FTunnelPassword);
+      RawByteString ATunnelPassword = Storage->ReadStringAsBinaryData(L"TunnelPassword", FTunnelPassword);
+      SET_SESSION_PROPERTY_FROM(TunnelPassword, ATunnelPassword);
     }
   }
   TunnelPublicKeyFile = Storage->ReadString(L"TunnelPublicKeyFile", TunnelPublicKeyFile);
@@ -787,7 +796,8 @@ void __fastcall TSessionData::DoLoad(THierarchicalStorage * Storage, bool PuttyI
   }
   else
   {
-    FEncryptKey = Storage->ReadStringAsBinaryData(L"EncryptKey", FEncryptKey);
+    RawByteString AEncryptKey = Storage->ReadStringAsBinaryData(L"EncryptKey", FEncryptKey);
+    SET_SESSION_PROPERTY_FROM(EncryptKey, AEncryptKey);
   }
 
   IsWorkspace = Storage->ReadBool(L"IsWorkspace", IsWorkspace);

+ 0 - 3
source/core/SessionData.h

@@ -10,9 +10,6 @@
 #include "Configuration.h"
 #include <Xml.XMLIntf.hpp>
 //---------------------------------------------------------------------------
-#define SET_SESSION_PROPERTY(Property) \
-  if (F##Property != value) { F##Property = value; Modify(); }
-//---------------------------------------------------------------------------
 enum TCipher { cipWarn, cip3DES, cipBlowfish, cipAES, cipDES, cipArcfour, cipChaCha20 };
 #define CIPHER_COUNT (cipChaCha20+1)
 // explicit values to skip obsoleted fsExternalSSH, fsExternalSFTP