ソースを参照

Updating code to PuTTY 0.75

(cherry picked from commit b69328d92d8e6fbdaed8b3b9b532deaa8bcc8519)

# Conflicts:
#	source/putty/sshecc.c

Source commit: 93ff727e4e428f747ab8f6b0d2db8147905b9e26
Martin Prikryl 4 年 前
コミット
542b4ead44
49 ファイル変更1095 行追加803 行削除
  1. 12 0
      source/Putty.cbproj
  2. 20 11
      source/core/PuttyIntf.cpp
  3. 33 17
      source/core/SecureShell.cpp
  4. 2 1
      source/core/SecureShell.h
  5. 2 2
      source/core/SessionData.cpp
  6. 1 1
      source/core/SessionData.h
  7. 23 22
      source/putty/agentf.c
  8. 6 4
      source/putty/errsock.c
  9. 6 0
      source/putty/import.c
  10. 23 22
      source/putty/mainchan.c
  11. 53 14
      source/putty/mpint.c
  12. 2 0
      source/putty/network.h
  13. 6 4
      source/putty/nullplug.c
  14. 35 29
      source/putty/portfwd.c
  15. 15 13
      source/putty/proxy.c
  16. 61 46
      source/putty/ssh.c
  17. 3 1
      source/putty/ssh.h
  18. 7 6
      source/putty/ssh1bpp.c
  19. 17 13
      source/putty/ssh1connection-client.c
  20. 36 31
      source/putty/ssh1connection.c
  21. 10 9
      source/putty/ssh1login.c
  22. 7 6
      source/putty/ssh2bpp-bare.c
  23. 7 6
      source/putty/ssh2bpp.c
  24. 2 0
      source/putty/ssh2connection-client.c
  25. 58 53
      source/putty/ssh2connection.c
  26. 11 1
      source/putty/ssh2kex-client.c
  27. 28 21
      source/putty/ssh2transport.c
  28. 11 9
      source/putty/ssh2userauth.c
  29. 52 40
      source/putty/sshaes.c
  30. 30 24
      source/putty/ssharcf.c
  31. 44 35
      source/putty/sshblowf.c
  32. 29 25
      source/putty/sshccp.c
  33. 26 23
      source/putty/sshcommon.c
  34. 75 59
      source/putty/sshdes.c
  35. 17 15
      source/putty/sshdss.c
  36. 96 80
      source/putty/sshecc.c
  37. 72 64
      source/putty/sshhmac.c
  38. 9 2
      source/putty/sshprng.c
  39. 23 6
      source/putty/sshpubk.c
  40. 33 24
      source/putty/sshrsa.c
  41. 10 5
      source/putty/sshshare.c
  42. 7 6
      source/putty/sshverstring.c
  43. 10 9
      source/putty/sshzlib.c
  44. 2 1
      source/putty/utils.c
  45. 6 0
      source/putty/windows/winhandl.c
  46. 9 8
      source/putty/windows/winhsock.c
  47. 11 8
      source/putty/windows/winnet.c
  48. 8 1
      source/putty/windows/winpgntc.c
  49. 29 26
      source/putty/x11fwd.c

+ 12 - 0
source/Putty.cbproj

@@ -308,9 +308,15 @@
 			<BuildOrder>71</BuildOrder>
 			<BuildOrder>7</BuildOrder>
 		</CppCompile>
+		<CppCompile Include="putty\sshsha3.c">
+			<BuildOrder>42</BuildOrder>
+		</CppCompile>
 		<CppCompile Include="putty\sshshare.c">
 			<BuildOrder>42</BuildOrder>
 		</CppCompile>
+		<CppCompile Include="putty\sshutils.c">
+			<BuildOrder>63</BuildOrder>
+		</CppCompile>
 		<CppCompile Include="putty\sshverstring.c">
 			<BuildOrder>63</BuildOrder>
 		</CppCompile>
@@ -332,6 +338,9 @@
 			<BuildOrder>83</BuildOrder>
 			<BuildOrder>3</BuildOrder>
 		</CppCompile>
+		<CppCompile Include="putty\windows\wincapi.c">
+			<BuildOrder>83</BuildOrder>
+		</CppCompile>
 		<CppCompile Include="putty\windows\windefs.c">
 			<BuildOrder>83</BuildOrder>
 		</CppCompile>
@@ -363,6 +372,9 @@
 		<CppCompile Include="putty\windows\winnojmp.c">
 			<BuildOrder>39</BuildOrder>
 		</CppCompile>
+		<CppCompile Include="putty\windows\winnpc.c">
+			<BuildOrder>39</BuildOrder>
+		</CppCompile>
 		<CppCompile Include="putty\windows\winpgntc.c">
 			<BuildOrder>13</BuildOrder>
 			<BuildOrder>101</BuildOrder>

+ 20 - 11
source/core/PuttyIntf.cpp

@@ -2,7 +2,6 @@
 #include <vcl.h>
 #pragma hdrstop
 
-#define PUTTY_DO_GLOBALS
 #include "PuttyIntf.h"
 #include "Interface.h"
 #include "SecureShell.h"
@@ -45,8 +44,6 @@ void __fastcall PuttyInitialize()
   // in destructor can proceed
   random_ref();
 
-  flags = FLAG_VERBOSE | FLAG_SYNCAGENT; // verbose log
-
   sk_init();
 
   AnsiString VersionString = AnsiString(SshVersionString());
@@ -134,7 +131,7 @@ struct callback_set * get_seat_callback_set(Seat * seat)
   return SecureShell->GetCallbackSet();
 }
 //---------------------------------------------------------------------------
-extern "C" char * do_select(Plug * plug, SOCKET skt, bool enable)
+extern "C" const char * do_select(Plug * plug, SOCKET skt, bool enable)
 {
   bool pfwd;
   TSecureShell * SecureShell = GetSecureShell(plug, pfwd);
@@ -250,11 +247,20 @@ static void connection_fatal(Seat * seat, const char * message)
 }
 //---------------------------------------------------------------------------
 int verify_ssh_host_key(Seat * seat, const char * host, int port, const char * keytype,
-  char * keystr, char * fingerprint, void (*/*callback*/)(void * ctx, int result),
-  void * /*ctx*/)
+  char * keystr, const char * DebugUsedArg(keydisp), char ** key_fingerprints,
+  void (*DebugUsedArg(callback))(void *ctx, int result), void * DebugUsedArg(ctx))
 {
+  UnicodeString FingerprintSHA256, FingerprintMD5;
+  if (key_fingerprints[SSH_FPTYPE_SHA256] != NULL)
+  {
+    FingerprintSHA256 = key_fingerprints[SSH_FPTYPE_SHA256];
+  }
+  if (DebugAlwaysTrue(key_fingerprints[SSH_FPTYPE_MD5] != NULL))
+  {
+    FingerprintMD5 = key_fingerprints[SSH_FPTYPE_MD5];
+  }
   TSecureShell * SecureShell = static_cast<ScpSeat *>(seat)->SecureShell;
-  SecureShell->VerifyHostKey(host, port, keytype, keystr, fingerprint);
+  SecureShell->VerifyHostKey(host, port, keytype, keystr, FingerprintSHA256, FingerprintMD5);
 
   // We should return 0 when key was not confirmed, we throw exception instead.
   return 1;
@@ -393,7 +399,10 @@ static const SeatVtable ScpSeatVtable =
     nullseat_get_windowid,
     nullseat_get_window_pixel_size,
     nullseat_stripctrl_new,
-    nullseat_set_trust_status_vacuously
+    nullseat_set_trust_status_vacuously,
+    nullseat_verbose_yes,
+    nullseat_interactive_no,
+    nullseat_get_cursor_position,
   };
 //---------------------------------------------------------------------------
 ScpSeat::ScpSeat(TSecureShell * ASecureShell)
@@ -609,7 +618,7 @@ bool IsKeyEncrypted(TKeyType KeyType, const UnicodeString & FileName, UnicodeStr
     switch (KeyType)
     {
       case ktSSH2:
-        Result = (ssh2_userkey_encrypted(KeyFile, &CommentStr) != 0);
+        Result = (ppk_encrypted_f(KeyFile, &CommentStr) != 0);
         break;
 
       case ktOpenSSHPEM:
@@ -655,7 +664,7 @@ TPrivateKey * LoadKey(TKeyType KeyType, const UnicodeString & FileName, const Un
     switch (KeyType)
     {
       case ktSSH2:
-        Ssh2Key = ssh2_load_userkey(KeyFile, AnsiPassphrase.c_str(), &ErrorStr);
+        Ssh2Key = ppk_load_f(KeyFile, AnsiPassphrase.c_str(), &ErrorStr);
         break;
 
       case ktOpenSSHPEM:
@@ -754,7 +763,7 @@ RawByteString LoadPublicKey(const UnicodeString & FileName, UnicodeString & Algo
     char * CommentStr = NULL;
     const char * ErrorStr = NULL;
     strbuf * PublicKeyBuf = strbuf_new();
-    if (!ssh2_userkey_loadpub(KeyFile, &AlgorithmStr, BinarySink_UPCAST(PublicKeyBuf), &CommentStr, &ErrorStr))
+    if (!ppk_loadpub_f(KeyFile, &AlgorithmStr, BinarySink_UPCAST(PublicKeyBuf), &CommentStr, &ErrorStr))
     {
       UnicodeString Error = UnicodeString(AnsiString(ErrorStr));
       throw Exception(Error);

+ 33 - 17
source/core/SecureShell.cpp

@@ -229,6 +229,7 @@ Conf * __fastcall TSecureShell::StoreToConfig(TSessionData * Data, bool Simple)
       case hkDSA: phk = hkDSA; break;
       case hkECDSA: phk = HK_ECDSA; break;
       case hkED25519: phk = HK_ED25519; break;
+      case hkED448: phk = HK_ED448; break;
       default: DebugFail();
     }
     conf_set_int_int(conf, CONF_ssh_hklist, h, phk);
@@ -408,6 +409,7 @@ static const LogPolicyVtable ScpLogPolicyVTable =
     eventlog,
     NULL, // Should never be called
     NULL, // Should never be called
+    null_lp_verbose_no, // Should never be called
   };
 //---------------------------------------------------------------------------
 void __fastcall TSecureShell::Open()
@@ -2411,13 +2413,30 @@ UnicodeString TSecureShell::StoreHostKey(
   return Storage->Source;
 }
 //---------------------------------------------------------------------------
+void TSecureShell::ParseFingerprint(const UnicodeString & Fingerprint, UnicodeString & SignKeyType, UnicodeString & Hash)
+{
+  UnicodeString Buf = Fingerprint;
+  UnicodeString SignKeyAlg, SignKeySize;
+  if (get_ssh_version(FBackendHandle) == 1)
+  {
+    SignKeyAlg = GetSsh1KeyType();
+  }
+  else
+  {
+    SignKeyAlg = CutToChar(Buf, L' ', false);
+  }
+  SignKeySize = CutToChar(Buf, L' ', false);
+  SignKeyType = SignKeyAlg + L' ' + SignKeySize;
+  Hash = Buf;
+}
+//---------------------------------------------------------------------------
 void __fastcall TSecureShell::VerifyHostKey(
   const UnicodeString & AHost, int Port, const UnicodeString & KeyType, const UnicodeString & KeyStr,
-  const UnicodeString & Fingerprint)
+  const UnicodeString & AFingerprintSHA256, const UnicodeString & AFingerprintMD5)
 {
   if (Configuration->ActualLogProtocol >= 1)
   {
-    LogEvent(FORMAT(L"Verifying host key %s %s with fingerprints %s", (KeyType, FormatKeyStr(KeyStr), Fingerprint)));
+    LogEvent(FORMAT(L"Verifying host key %s %s with fingerprints %s, %s", (KeyType, FormatKeyStr(KeyStr), AFingerprintSHA256, AFingerprintMD5)));
   }
 
   GotHostKey();
@@ -2427,30 +2446,27 @@ void __fastcall TSecureShell::VerifyHostKey(
   UnicodeString Host = AHost;
   GetRealHost(Host, Port);
 
-  UnicodeString Buf = Fingerprint;
-  UnicodeString SignKeyAlg, SignKeySize, MD5, SHA256;
-  if (get_ssh_version(FBackendHandle) == 1)
-  {
-    SignKeyAlg = GetSsh1KeyType();
-  }
-  else
-  {
-    SignKeyAlg = CutToChar(Buf, L' ', false);
-  }
-  SignKeySize = CutToChar(Buf, L' ', false);
-  MD5 = CutToChar(Buf, L' ', false);
+  UnicodeString SignKeyType, MD5, SHA256;
+  ParseFingerprint(AFingerprintMD5, SignKeyType, MD5);
   if (get_ssh_version(FBackendHandle) == 1)
   {
+    DebugAssert(AFingerprintSHA256.IsEmpty());
     SHA256 = L"-";
-    DebugAssert(Buf.IsEmpty());
   }
   else
   {
-    SHA256 = Buf;
+    UnicodeString SignKeyTypeSHA256;
+    ParseFingerprint(AFingerprintSHA256, SignKeyTypeSHA256, SHA256);
+    DebugAssert(SignKeyTypeSHA256 == SignKeyType);
+    if (DebugAlwaysTrue(StartsText(L"SHA256:", SHA256)))
+    {
+      CutToChar(SHA256, L':', false);
+    }
   }
-  UnicodeString SignKeyType = SignKeyAlg + L' ' + SignKeySize;
   UnicodeString FingerprintMD5 = SignKeyType + L' ' + MD5;
+  DebugAssert(AFingerprintMD5 == FingerprintMD5);
   UnicodeString FingerprintSHA256 = SignKeyType + L' ' + SHA256;
+  DebugAssert(ReplaceStr(AFingerprintSHA256, L"SHA256:", EmptyStr) == FingerprintSHA256);
 
   FSessionInfo.HostKeyFingerprintSHA256 = FingerprintSHA256;
   FSessionInfo.HostKeyFingerprintMD5 = FingerprintMD5;

+ 2 - 1
source/core/SecureShell.h

@@ -124,6 +124,7 @@ protected:
   void __fastcall inline LogEvent(const UnicodeString & Str);
   void __fastcall FatalError(UnicodeString Error, UnicodeString HelpKeyword = L"");
   UnicodeString __fastcall FormatKeyStr(UnicodeString KeyStr);
+  void ParseFingerprint(const UnicodeString & Fingerprint, UnicodeString & SignKeyType, UnicodeString & Hash);
   static Conf * __fastcall StoreToConfig(TSessionData * Data, bool Simple);
 
 public:
@@ -169,7 +170,7 @@ public:
   const UnicodeString & __fastcall GetStdError();
   void __fastcall VerifyHostKey(
     const UnicodeString & Host, int Port, const UnicodeString & KeyType, const UnicodeString & KeyStr,
-    const UnicodeString & Fingerprint);
+    const UnicodeString & FingerprintSHA256, const UnicodeString & FingerprintMD5);
   bool __fastcall HaveHostKey(UnicodeString Host, int Port, const UnicodeString KeyType);
   void __fastcall AskAlg(UnicodeString AlgType, UnicodeString AlgName);
   void __fastcall DisplayBanner(const UnicodeString & Banner);

+ 2 - 2
source/core/SessionData.cpp

@@ -32,7 +32,7 @@ const wchar_t * ProxyMethodNames = L"None;SOCKS4;SOCKS5;HTTP;Telnet;Cmd";
 const wchar_t * DefaultName = L"Default Settings";
 const UnicodeString CipherNames[CIPHER_COUNT] = {L"WARN", L"3des", L"blowfish", L"aes", L"des", L"arcfour", L"chacha20"};
 const UnicodeString KexNames[KEX_COUNT] = {L"WARN", L"dh-group1-sha1", L"dh-group14-sha1", L"dh-gex-sha1", L"rsa", L"ecdh"};
-const UnicodeString HostKeyNames[HOSTKEY_COUNT] = {L"WARN", L"rsa", L"dsa", L"ecdsa", L"ed25519"};
+const UnicodeString HostKeyNames[HOSTKEY_COUNT] = {L"WARN", L"rsa", L"dsa", L"ecdsa", L"ed25519", L"ed448"};
 const UnicodeString GssLibNames[GSSLIB_COUNT] = {L"gssapi32", L"sspi", L"custom"};
 const wchar_t SshProtList[][10] = {L"1", L"1>2", L"2>1", L"2"};
 // Update also order in Ssh2CipherList()
@@ -42,7 +42,7 @@ const TCipher DefaultCipherList[CIPHER_COUNT] =
 const TKex DefaultKexList[KEX_COUNT] =
   { kexECDH, kexDHGEx, kexDHGroup14, kexRSA, kexWarn, kexDHGroup1 };
 const THostKey DefaultHostKeyList[HOSTKEY_COUNT] =
-  { hkED25519, hkECDSA, hkRSA, hkDSA, hkWarn };
+  { hkED448, hkED25519, hkECDSA, hkRSA, hkDSA, hkWarn };
 const TGssLib DefaultGssLibList[GSSLIB_COUNT] =
   { gssGssApi32, gssSspi, gssCustom };
 const wchar_t FSProtocolNames[FSPROTOCOL_COUNT][16] = { L"SCP", L"SFTP (SCP)", L"SFTP", L"", L"", L"FTP", L"WebDAV", L"S3" };

+ 1 - 1
source/core/SessionData.h

@@ -20,7 +20,7 @@ enum TProxyMethod { pmNone, pmSocks4, pmSocks5, pmHTTP, pmTelnet, pmCmd };
 enum TSshProt { ssh1only, ssh1deprecated, ssh2deprecated, ssh2only };
 enum TKex { kexWarn, kexDHGroup1, kexDHGroup14, kexDHGEx, kexRSA, kexECDH };
 #define KEX_COUNT (kexECDH+1)
-enum THostKey { hkWarn, hkRSA, hkDSA, hkECDSA, hkED25519, hkMax };
+enum THostKey { hkWarn, hkRSA, hkDSA, hkECDSA, hkED25519, hkED448, hkMax };
 #define HOSTKEY_COUNT (hkMax)
 enum TGssLib { gssGssApi32, gssSspi, gssCustom };
 #define GSSLIB_COUNT (gssCustom+1)

+ 23 - 22
source/putty/agentf.c

@@ -148,28 +148,29 @@ static char *agentf_log_close_msg(Channel *chan);
 static void agentf_set_input_wanted(Channel *chan, bool wanted);
 
 static const ChannelVtable agentf_channelvt = {
-    .free = agentf_free,
-    .open_confirmation = chan_remotely_opened_confirmation,
-    .open_failed = chan_remotely_opened_failure,
-    .send = agentf_send,
-    .send_eof = agentf_send_eof,
-    .set_input_wanted = agentf_set_input_wanted,
-    .log_close_msg = agentf_log_close_msg,
-    .want_close = chan_default_want_close,
-    .rcvd_exit_status = chan_no_exit_status,
-    .rcvd_exit_signal = chan_no_exit_signal,
-    .rcvd_exit_signal_numeric = chan_no_exit_signal_numeric,
-    .run_shell = chan_no_run_shell,
-    .run_command = chan_no_run_command,
-    .run_subsystem = chan_no_run_subsystem,
-    .enable_x11_forwarding = chan_no_enable_x11_forwarding,
-    .enable_agent_forwarding = chan_no_enable_agent_forwarding,
-    .allocate_pty = chan_no_allocate_pty,
-    .set_env = chan_no_set_env,
-    .send_break = chan_no_send_break,
-    .send_signal = chan_no_send_signal,
-    .change_window_size = chan_no_change_window_size,
-    .request_response = chan_no_request_response,
+    // WINSCP
+    /*.free =*/ agentf_free,
+    /*.open_confirmation =*/ chan_remotely_opened_confirmation,
+    /*.open_failed =*/ chan_remotely_opened_failure,
+    /*.send =*/ agentf_send,
+    /*.send_eof =*/ agentf_send_eof,
+    /*.set_input_wanted =*/ agentf_set_input_wanted,
+    /*.log_close_msg =*/ agentf_log_close_msg,
+    /*.want_close =*/ chan_default_want_close,
+    /*.rcvd_exit_status =*/ chan_no_exit_status,
+    /*.rcvd_exit_signal =*/ chan_no_exit_signal,
+    /*.rcvd_exit_signal_numeric =*/ chan_no_exit_signal_numeric,
+    /*.run_shell =*/ chan_no_run_shell,
+    /*.run_command =*/ chan_no_run_command,
+    /*.run_subsystem =*/ chan_no_run_subsystem,
+    /*.enable_x11_forwarding =*/ chan_no_enable_x11_forwarding,
+    /*.enable_agent_forwarding =*/ chan_no_enable_agent_forwarding,
+    /*.allocate_pty =*/ chan_no_allocate_pty,
+    /*.set_env =*/ chan_no_set_env,
+    /*.send_break =*/ chan_no_send_break,
+    /*.send_signal =*/ chan_no_send_signal,
+    /*.change_window_size =*/ chan_no_change_window_size,
+    /*.request_response =*/ chan_no_request_response,
 };
 
 Channel *agentf_new(SshChannel *c)

+ 6 - 4
source/putty/errsock.c

@@ -45,10 +45,12 @@ static SocketPeerInfo *sk_error_peer_info(Socket *s)
 }
 
 static const SocketVtable ErrorSocket_sockvt = {
-    .plug = sk_error_plug,
-    .close = sk_error_close,
-    .socket_error = sk_error_socket_error,
-    .peer_info = sk_error_peer_info,
+    // WINSCP
+    /*.plug =*/ sk_error_plug,
+    /*.close =*/ sk_error_close,
+    NULL, NULL, NULL, NULL, // WINSCP
+    /*.socket_error =*/ sk_error_socket_error,
+    /*.peer_info =*/ sk_error_peer_info,
     /* other methods are NULL */
 };
 

+ 6 - 0
source/putty/import.c

@@ -94,10 +94,12 @@ bool import_encrypted(const Filename *filename, int type, char **comment)
     if (!lf)
         return false; /* couldn't even open the file */
 
+    { // WINSCP
     bool toret = import_encrypted_s(filename, BinarySource_UPCAST(lf),
                                     type, comment);
     lf_free(lf);
     return toret;
+    } // WINSCP
 }
 
 /*
@@ -116,10 +118,12 @@ int import_ssh1(const Filename *filename, int type,
     if (!lf)
         return false;
 
+    { // WINSCP
     int toret = import_ssh1_s(BinarySource_UPCAST(lf),
                               type, key, passphrase, errmsg_p);
     lf_free(lf);
     return toret;
+    } // WINSCP
 }
 
 /*
@@ -144,10 +148,12 @@ ssh2_userkey *import_ssh2(const Filename *filename, int type,
     if (!lf)
         return false;
 
+    { // WINSCP
     ssh2_userkey *toret = import_ssh2_s(BinarySource_UPCAST(lf),
                                         type, passphrase, errmsg_p);
     lf_free(lf);
     return toret;
+    } // WINSCP
 }
 
 /*

+ 23 - 22
source/putty/mainchan.c

@@ -27,28 +27,29 @@ static bool mainchan_rcvd_exit_signal_numeric(
 static void mainchan_request_response(Channel *chan, bool success);
 
 static const ChannelVtable mainchan_channelvt = {
-    .free = mainchan_free,
-    .open_confirmation = mainchan_open_confirmation,
-    .open_failed = mainchan_open_failure,
-    .send = mainchan_send,
-    .send_eof = mainchan_send_eof,
-    .set_input_wanted = mainchan_set_input_wanted,
-    .log_close_msg = mainchan_log_close_msg,
-    .want_close = chan_default_want_close,
-    .rcvd_exit_status = mainchan_rcvd_exit_status,
-    .rcvd_exit_signal = mainchan_rcvd_exit_signal,
-    .rcvd_exit_signal_numeric = mainchan_rcvd_exit_signal_numeric,
-    .run_shell = chan_no_run_shell,
-    .run_command = chan_no_run_command,
-    .run_subsystem = chan_no_run_subsystem,
-    .enable_x11_forwarding = chan_no_enable_x11_forwarding,
-    .enable_agent_forwarding = chan_no_enable_agent_forwarding,
-    .allocate_pty = chan_no_allocate_pty,
-    .set_env = chan_no_set_env,
-    .send_break = chan_no_send_break,
-    .send_signal = chan_no_send_signal,
-    .change_window_size = chan_no_change_window_size,
-    .request_response = mainchan_request_response,
+    // WINSCP
+    /*.free =*/ mainchan_free,
+    /*.open_confirmation =*/ mainchan_open_confirmation,
+    /*.open_failed =*/ mainchan_open_failure,
+    /*.send =*/ mainchan_send,
+    /*.send_eof =*/ mainchan_send_eof,
+    /*.set_input_wanted =*/ mainchan_set_input_wanted,
+    /*.log_close_msg =*/ mainchan_log_close_msg,
+    /*.want_close =*/ chan_default_want_close,
+    /*.rcvd_exit_status =*/ mainchan_rcvd_exit_status,
+    /*.rcvd_exit_signal =*/ mainchan_rcvd_exit_signal,
+    /*.rcvd_exit_signal_numeric =*/ mainchan_rcvd_exit_signal_numeric,
+    /*.run_shell =*/ chan_no_run_shell,
+    /*.run_command =*/ chan_no_run_command,
+    /*.run_subsystem =*/ chan_no_run_subsystem,
+    /*.enable_x11_forwarding =*/ chan_no_enable_x11_forwarding,
+    /*.enable_agent_forwarding =*/ chan_no_enable_agent_forwarding,
+    /*.allocate_pty =*/ chan_no_allocate_pty,
+    /*.set_env =*/ chan_no_set_env,
+    /*.send_break =*/ chan_no_send_break,
+    /*.send_signal =*/ chan_no_send_signal,
+    /*.change_window_size =*/ chan_no_change_window_size,
+    /*.request_response =*/ mainchan_request_response,
 };
 
 typedef enum MainChanType {

+ 53 - 14
source/putty/mpint.c

@@ -125,7 +125,8 @@ void mp_copy_into(mp_int *dest, mp_int *src)
 
 void mp_copy_integer_into(mp_int *r, uintmax_t n)
 {
-    for (size_t i = 0; i < r->nw; i++) {
+    size_t i; // WINSCP
+    for (i = 0; i < r->nw; i++) {
         r->w[i] = n;
         n = shift_right_by_one_word(n);
     }
@@ -1305,24 +1306,33 @@ static void mp_lshift_safe_in_place(mp_int *r, size_t bits)
     unsigned clear = (r->nw - wordshift) >> (CHAR_BIT * sizeof(size_t) - 1);
     mp_cond_clear(r, clear);
 
-    for (unsigned bit = 0; r->nw >> bit; bit++) {
+    { // WINSCP
+    unsigned bit; // WINSCP
+    for (bit = 0; r->nw >> bit; bit++) {
         size_t word_offset = (size_t)1 << bit;
         BignumInt mask = -(BignumInt)((wordshift >> bit) & 1);
-        for (size_t i = r->nw; i-- > 0 ;) {
+        size_t i; // WINSCP
+        for (i = r->nw; i-- > 0 ;) {
             BignumInt w = mp_word(r, i - word_offset);
             r->w[i] ^= (r->w[i] ^ w) & mask;
         }
     }
 
+    { // WINSCP
     size_t downshift = BIGNUM_INT_BITS - bitshift;
     size_t no_shift = (downshift >> BIGNUM_INT_BITS_BITS);
     downshift &= ~-(size_t)no_shift;
+    { // WINSCP
     BignumInt downshifted_mask = ~-(BignumInt)no_shift;
 
-    for (size_t i = r->nw; i-- > 0 ;) {
+    size_t i; // WINSCP
+    for (i = r->nw; i-- > 0 ;) {
         r->w[i] = (r->w[i] << bitshift) |
             ((mp_word(r, i-1) >> downshift) & downshifted_mask);
     }
+    } // WINSCP
+    } // WINSCP
+    } // WINSCP
 }
 
 void mp_lshift_safe_into(mp_int *r, mp_int *x, size_t bits)
@@ -1889,7 +1899,8 @@ static void mp_bezout_into(mp_int *a_coeff_out, mp_int *b_coeff_out,
         { // WINSCP
         unsigned minus_d = b->w[0];
 
-        for (size_t step = steps; step-- > 0 ;) {
+        size_t step; // WINSCP
+        for (step = steps; step-- > 0 ;) {
             /*
              * Recover the data from the step we're unwinding.
              */
@@ -1954,6 +1965,7 @@ static void mp_bezout_into(mp_int *a_coeff_out, mp_int *b_coeff_out,
         if (b_coeff_out)
             mp_copy_into(b_coeff_out, bc);
 
+        } // WINSCP
     }
 
     mp_free(a);
@@ -1963,7 +1975,6 @@ static void mp_bezout_into(mp_int *a_coeff_out, mp_int *b_coeff_out,
     mp_free(tmp);
     mp_free(record);
     } // WINSCP
-    } // WINSCP
 }
 
 mp_int *mp_invert(mp_int *x, mp_int *m)
@@ -1983,14 +1994,18 @@ void mp_gcd_into(mp_int *a, mp_int *b, mp_int *gcd, mp_int *A, mp_int *B)
      * set bit.
      */
     mp_int *tmp = mp_make_sized(size_t_max(a->nw, b->nw));
-    for (size_t i = 0; i < tmp->nw; i++)
+    size_t i; // WINSCP
+    for (i = 0; i < tmp->nw; i++)
         tmp->w[i] = mp_word(a, i) | mp_word(b, i);
+    { // WINSCP
     BignumCarry carry = 1;
-    for (size_t i = 0; i < tmp->nw; i++) {
+    size_t i;
+    for (i = 0; i < tmp->nw; i++) {
         BignumInt negw;
         BignumADC(negw, carry, 0, ~tmp->w[i], carry);
         tmp->w[i] &= negw;
     }
+    { // WINSCP
     size_t shift = mp_get_nbits(tmp) - 1;
     mp_free(tmp);
 
@@ -1999,6 +2014,7 @@ void mp_gcd_into(mp_int *a, mp_int *b, mp_int *gcd, mp_int *A, mp_int *B)
      * so that at least one is odd (which is the precondition for
      * mp_bezout_into). Compute the gcd of those.
      */
+    { // WINSCP
     mp_int *as = mp_rshift_safe(a, shift);
     mp_int *bs = mp_rshift_safe(b, shift);
     mp_bezout_into(A, B, gcd, as, bs);
@@ -2011,6 +2027,9 @@ void mp_gcd_into(mp_int *a, mp_int *b, mp_int *gcd, mp_int *A, mp_int *B)
      */
     if (gcd)
         mp_lshift_safe_in_place(gcd, shift);
+    } // WINSCP
+    } // WINSCP
+    } // WINSCP
 }
 
 mp_int *mp_gcd(mp_int *a, mp_int *b)
@@ -2397,7 +2416,9 @@ mp_int *mp_nthroot(mp_int *y, unsigned n, mp_int *remainder_out)
     mp_int **alloc, **powers, **newpowers, *scratch;
     size_t nalloc = 2*(n+1)+1;
     alloc = snewn(nalloc, mp_int *);
-    for (size_t i = 0; i < nalloc; i++)
+    { // WINSCP
+    size_t i; // WINSCP
+    for (i = 0; i < nalloc; i++)
         alloc[i] = mp_make_sized(y->nw + 1);
     powers = alloc;
     newpowers = alloc + (n+1);
@@ -2415,12 +2436,15 @@ mp_int *mp_nthroot(mp_int *y, unsigned n, mp_int *remainder_out)
      * to match.
      */
     mp_copy_integer_into(powers[0], 1);
-    for (size_t s = mp_max_bits(y) / n + 1; s-- > 0 ;) {
+    { // WINSCP
+    size_t s; // WINSCP
+    for (s = mp_max_bits(y) / n + 1; s-- > 0 ;) {
         /*
          * Let b = 2^s. We need to compute the powers (x+b)^i for each
          * i, starting from our recorded values of x^i.
          */
-        for (size_t i = 0; i < n+1; i++) {
+        size_t i; // WINSCP
+        for (i = 0; i < n+1; i++) {
             /*
              * (x+b)^i = x^i
              *         + (i choose 1) x^{i-1} b
@@ -2430,39 +2454,54 @@ mp_int *mp_nthroot(mp_int *y, unsigned n, mp_int *remainder_out)
              */
             uint16_t binom = 1;       /* coefficient of b^i */
             mp_copy_into(newpowers[i], powers[i]);
-            for (size_t j = 0; j < i; j++) {
+            { // WINSCP
+            size_t j; // WINSCP
+            for (j = 0; j < i; j++) {
                 /* newpowers[i] += binom * powers[j] * 2^{(i-j)*s} */
                 mp_mul_integer_into(scratch, powers[j], binom);
                 mp_lshift_fixed_into(scratch, scratch, (i-j) * s);
                 mp_add_into(newpowers[i], newpowers[i], scratch);
 
+                { // WINSCP
                 uint32_t binom_mul = binom;
                 binom_mul *= (i-j);
                 binom_mul /= (j+1);
                 assert(binom_mul < 0x10000);
                 binom = binom_mul;
+                } // WINSCP
             }
+            } // WINSCP
         }
 
         /*
          * Now, is the new value of x^n still <= y? If so, update.
          */
+        { // WINSCP
         unsigned newbit = mp_cmp_hs(y, newpowers[n]);
-        for (size_t i = 0; i < n+1; i++)
+        size_t i; // WINSCP
+        for (i = 0; i < n+1; i++)
             mp_select_into(powers[i], powers[i], newpowers[i], newbit);
+        } // WINSCP
     }
 
     if (remainder_out)
         mp_sub_into(remainder_out, y, powers[n]);
 
+    { // WINSCP
     mp_int *root = mp_new(mp_max_bits(y) / n);
     mp_copy_into(root, powers[1]);
 
-    for (size_t i = 0; i < nalloc; i++)
+    { // WINSCP
+    size_t i;
+    for (i = 0; i < nalloc; i++)
         mp_free(alloc[i]);
     sfree(alloc);
 
     return root;
+    } // WINSCP
+    } // WINSCP
+    } // WINSCP
+    } // WINSCP
 }
 
 mp_int *mp_modmul(mp_int *x, mp_int *y, mp_int *modulus)

+ 2 - 0
source/putty/network.h

@@ -179,9 +179,11 @@ static inline size_t sk_write_oob(Socket *s, const void *data, size_t len)
 static inline void sk_write_eof(Socket *s)
 { s->vt->write_eof(s); }
 
+#pragma option push -w-bei // WINSCP
 static inline void plug_log(
     Plug *p, int type, SockAddr *addr, int port, const char *msg, int code)
 { p->vt->log(p, type, addr, port, msg, code); }
+#pragma option pop // WINSCP
 static inline void plug_closing(
     Plug *p, const char *msg, int code, bool calling_back)
 { p->vt->closing(p, msg, code, calling_back); }

+ 6 - 4
source/putty/nullplug.c

@@ -27,10 +27,12 @@ static void nullplug_sent(Plug *plug, size_t bufsize)
 }
 
 static const PlugVtable nullplug_plugvt = {
-    .log = nullplug_socket_log,
-    .closing = nullplug_closing,
-    .receive = nullplug_receive,
-    .sent = nullplug_sent,
+    // WINSCP
+    /*.log =*/ nullplug_socket_log,
+    /*.closing =*/ nullplug_closing,
+    /*.receive =*/ nullplug_receive,
+    /*.sent =*/ nullplug_sent,
+    NULL, // WINSCP
 };
 
 static Plug nullplug_plug = { &nullplug_plugvt };

+ 35 - 29
source/putty/portfwd.c

@@ -427,10 +427,12 @@ static void pfd_sent(Plug *plug, size_t bufsize)
 }
 
 static const PlugVtable PortForwarding_plugvt = {
-    .log = pfd_log,
-    .closing = pfd_closing,
-    .receive = pfd_receive,
-    .sent = pfd_sent,
+    // WINSCP
+    /*.log =*/ pfd_log,
+    /*.closing =*/ pfd_closing,
+    /*.receive =*/ pfd_receive,
+    /*.sent =*/ pfd_sent,
+    NULL,
 };
 
 static void pfd_chan_free(Channel *chan);
@@ -443,28 +445,29 @@ static void pfd_set_input_wanted(Channel *chan, bool wanted);
 static char *pfd_log_close_msg(Channel *chan);
 
 static const ChannelVtable PortForwarding_channelvt = {
-    .free = pfd_chan_free,
-    .open_confirmation = pfd_open_confirmation,
-    .open_failed = pfd_open_failure,
-    .send = pfd_send,
-    .send_eof = pfd_send_eof,
-    .set_input_wanted = pfd_set_input_wanted,
-    .log_close_msg = pfd_log_close_msg,
-    .want_close = chan_default_want_close,
-    .rcvd_exit_status = chan_no_exit_status,
-    .rcvd_exit_signal = chan_no_exit_signal,
-    .rcvd_exit_signal_numeric = chan_no_exit_signal_numeric,
-    .run_shell = chan_no_run_shell,
-    .run_command = chan_no_run_command,
-    .run_subsystem = chan_no_run_subsystem,
-    .enable_x11_forwarding = chan_no_enable_x11_forwarding,
-    .enable_agent_forwarding = chan_no_enable_agent_forwarding,
-    .allocate_pty = chan_no_allocate_pty,
-    .set_env = chan_no_set_env,
-    .send_break = chan_no_send_break,
-    .send_signal = chan_no_send_signal,
-    .change_window_size = chan_no_change_window_size,
-    .request_response = chan_no_request_response,
+    // WINSCP
+    /*.free =*/ pfd_chan_free,
+    /*.open_confirmation =*/ pfd_open_confirmation,
+    /*.open_failed =*/ pfd_open_failure,
+    /*.send =*/ pfd_send,
+    /*.send_eof =*/ pfd_send_eof,
+    /*.set_input_wanted =*/ pfd_set_input_wanted,
+    /*.log_close_msg =*/ pfd_log_close_msg,
+    /*.want_close =*/ chan_default_want_close,
+    /*.rcvd_exit_status =*/ chan_no_exit_status,
+    /*.rcvd_exit_signal =*/ chan_no_exit_signal,
+    /*.rcvd_exit_signal_numeric =*/ chan_no_exit_signal_numeric,
+    /*.run_shell =*/ chan_no_run_shell,
+    /*.run_command =*/ chan_no_run_command,
+    /*.run_subsystem =*/ chan_no_run_subsystem,
+    /*.enable_x11_forwarding =*/ chan_no_enable_x11_forwarding,
+    /*.enable_agent_forwarding =*/ chan_no_enable_agent_forwarding,
+    /*.allocate_pty =*/ chan_no_allocate_pty,
+    /*.set_env =*/ chan_no_set_env,
+    /*.send_break =*/ chan_no_send_break,
+    /*.send_signal =*/ chan_no_send_signal,
+    /*.change_window_size =*/ chan_no_change_window_size,
+    /*.request_response =*/ chan_no_request_response,
 };
 
 Channel *portfwd_raw_new(ConnectionLayer *cl, Plug **plug, bool start_ready)
@@ -550,9 +553,12 @@ static int pfl_accepting(Plug *p, accept_fn_t constructor, accept_ctx_t ctx)
 }
 
 static const PlugVtable PortListener_plugvt = {
-    .log = pfl_log,
-    .closing = pfl_closing,
-    .accepting = pfl_accepting,
+    // WINSCP
+    /*.log =*/ pfl_log,
+    /*.closing =*/ pfl_closing,
+    NULL,
+    NULL,
+    /*.accepting =*/ pfl_accepting,
 };
 
 /*

+ 15 - 13
source/putty/proxy.c

@@ -372,22 +372,24 @@ SockAddr *name_lookup(const char *host, int port, char **canonicalname,
 }
 
 static const SocketVtable ProxySocket_sockvt = {
-    .plug = sk_proxy_plug,
-    .close = sk_proxy_close,
-    .write = sk_proxy_write,
-    .write_oob = sk_proxy_write_oob,
-    .write_eof = sk_proxy_write_eof,
-    .set_frozen = sk_proxy_set_frozen,
-    .socket_error = sk_proxy_socket_error,
-    .peer_info = NULL,
+    // WINSCP
+    /*.plug =*/ sk_proxy_plug,
+    /*.close =*/ sk_proxy_close,
+    /*.write =*/ sk_proxy_write,
+    /*.write_oob =*/ sk_proxy_write_oob,
+    /*.write_eof =*/ sk_proxy_write_eof,
+    /*.set_frozen =*/ sk_proxy_set_frozen,
+    /*.socket_error =*/ sk_proxy_socket_error,
+    /*.peer_info =*/ NULL,
 };
 
 static const PlugVtable ProxySocket_plugvt = {
-    .log = plug_proxy_log,
-    .closing = plug_proxy_closing,
-    .receive = plug_proxy_receive,
-    .sent = plug_proxy_sent,
-    .accepting = plug_proxy_accepting
+    // WINSCP
+    /*.log =*/ plug_proxy_log,
+    /*.closing =*/ plug_proxy_closing,
+    /*.receive =*/ plug_proxy_receive,
+    /*.sent =*/ plug_proxy_sent,
+    /*.accepting =*/ plug_proxy_accepting
 };
 
 Socket *new_connection(SockAddr *addr, const char *hostname,

+ 61 - 46
source/putty/ssh.c

@@ -700,19 +700,25 @@ static char *ssh_close_warn_text(Backend *be)
     Ssh *ssh = container_of(be, Ssh, backend);
     if (!ssh->connshare)
         return NULL;
+    { // WINSCP
     int ndowns = share_ndownstreams(ssh->connshare);
     if (ndowns == 0)
         return NULL;
+    { // WINSCP
     char *msg = dupprintf("This will also close %d downstream connection%s.",
                           ndowns, ndowns==1 ? "" : "s");
     return msg;
+    } // WINSCP
+    } // WINSCP
 }
 
 static const PlugVtable Ssh_plugvt = {
-    .log = ssh_socket_log,
-    .closing = ssh_closing,
-    .receive = ssh_receive,
-    .sent = ssh_sent,
+    // WINSCP
+    /*.log =*/ ssh_socket_log,
+    /*.closing =*/ ssh_closing,
+    /*.receive =*/ ssh_receive,
+    /*.sent =*/ ssh_sent,
+    // NULL
 };
 
 /*
@@ -891,7 +897,10 @@ bool ssh_is_bare(Ssh *ssh)
  * because it might be called early due to plink -shareexists */
 static void dummy_sharing_no_more_downstreams(ConnectionLayer *cl) {}
 static const ConnectionLayerVtable dummy_connlayer_vtable = {
-    .sharing_no_more_downstreams = dummy_sharing_no_more_downstreams,
+    // WINSCP
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+    /*.sharing_no_more_downstreams =*/ dummy_sharing_no_more_downstreams,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
 };
 
 /*
@@ -936,6 +945,7 @@ static char *ssh_init(const BackendVtable *vt, Seat *seat,
     random_ref(); /* do this now - may be needed by sharing setup code */
     ssh->need_random_unref = true;
 
+    { // WINSCP
     char *conn_err = connect_to_host(
         ssh, host, port, realhost, nodelay, keepalive);
     if (conn_err) {
@@ -947,6 +957,7 @@ static char *ssh_init(const BackendVtable *vt, Seat *seat,
         random_unref();
         return conn_err;
     }
+    } // WINSCP
 
     return NULL;
 }
@@ -1215,50 +1226,54 @@ void ssh_got_fallback_cmd(Ssh *ssh)
 }
 
 const BackendVtable ssh_backend = {
-    .init = ssh_init,
-    .free = ssh_free,
-    .reconfig = ssh_reconfig,
-    .send = ssh_send,
-    .sendbuffer = ssh_sendbuffer,
-    .size = ssh_size,
-    .special = ssh_special,
-    .get_specials = ssh_get_specials,
-    .connected = ssh_connected,
-    .exitcode = ssh_return_exitcode,
-    .sendok = ssh_sendok,
-    .ldisc_option_state = ssh_ldisc,
-    .provide_ldisc = ssh_provide_ldisc,
-    .unthrottle = ssh_unthrottle,
-    .cfg_info = ssh_cfg_info,
-    .test_for_upstream = ssh_test_for_upstream,
-    .close_warn_text = ssh_close_warn_text,
-    .id = "ssh",
-    .displayname = "SSH",
-    .protocol = PROT_SSH,
-    .default_port = 22,
+    // WINSCP
+    /*.init =*/ ssh_init,
+    /*.free =*/ ssh_free,
+    /*.reconfig =*/ ssh_reconfig,
+    /*.send =*/ ssh_send,
+    /*.sendbuffer =*/ ssh_sendbuffer,
+    /*.size =*/ ssh_size,
+    /*.special =*/ ssh_special,
+    /*.get_specials =*/ ssh_get_specials,
+    /*.connected =*/ ssh_connected,
+    /*.exitcode =*/ ssh_return_exitcode,
+    /*.sendok =*/ ssh_sendok,
+    /*.ldisc_option_state =*/ ssh_ldisc,
+    /*.provide_ldisc =*/ ssh_provide_ldisc,
+    /*.unthrottle =*/ ssh_unthrottle,
+    /*.cfg_info =*/ ssh_cfg_info,
+    /*.test_for_upstream =*/ ssh_test_for_upstream,
+    /*.close_warn_text =*/ ssh_close_warn_text,
+    /*.id =*/ "ssh",
+    /*.displayname =*/ "SSH",
+    /*.protocol =*/ PROT_SSH,
+    /*.default_port =*/ 22,
+    0, 0, 0, // WINSCP
 };
 
 const BackendVtable sshconn_backend = {
-    .init = ssh_init,
-    .free = ssh_free,
-    .reconfig = ssh_reconfig,
-    .send = ssh_send,
-    .sendbuffer = ssh_sendbuffer,
-    .size = ssh_size,
-    .special = ssh_special,
-    .get_specials = ssh_get_specials,
-    .connected = ssh_connected,
-    .exitcode = ssh_return_exitcode,
-    .sendok = ssh_sendok,
-    .ldisc_option_state = ssh_ldisc,
-    .provide_ldisc = ssh_provide_ldisc,
-    .unthrottle = ssh_unthrottle,
-    .cfg_info = ssh_cfg_info,
-    .test_for_upstream = ssh_test_for_upstream,
-    .close_warn_text = ssh_close_warn_text,
-    .id = "ssh-connection",
-    .displayname = "Bare ssh-connection",
-    .protocol = PROT_SSHCONN,
+    // WINSCP
+    /*.init =*/ ssh_init,
+    /*.free =*/ ssh_free,
+    /*.reconfig =*/ ssh_reconfig,
+    /*.send =*/ ssh_send,
+    /*.sendbuffer =*/ ssh_sendbuffer,
+    /*.size =*/ ssh_size,
+    /*.special =*/ ssh_special,
+    /*.get_specials =*/ ssh_get_specials,
+    /*.connected =*/ ssh_connected,
+    /*.exitcode =*/ ssh_return_exitcode,
+    /*.sendok =*/ ssh_sendok,
+    /*.ldisc_option_state =*/ ssh_ldisc,
+    /*.provide_ldisc =*/ ssh_provide_ldisc,
+    /*.unthrottle =*/ ssh_unthrottle,
+    /*.cfg_info =*/ ssh_cfg_info,
+    /*.test_for_upstream =*/ ssh_test_for_upstream,
+    /*.close_warn_text =*/ ssh_close_warn_text,
+    /*.id =*/ "ssh-connection",
+    /*.displayname =*/ "Bare ssh-connection",
+    /*.protocol =*/ PROT_SSHCONN,
+    0, 0, 0, 0, // WINSCP
 };
 
 #ifdef MPEXT

+ 3 - 1
source/putty/ssh.h

@@ -836,6 +836,7 @@ enum kexlist {
     NKEXLIST
 };
 
+#pragma option push -w-mnc // WINSCP
 struct ssh_keyalg {
     /* Constructors that create an ssh_key */
     ssh_key *(*new_pub) (const ssh_keyalg *self, ptrlen pub);
@@ -860,8 +861,9 @@ struct ssh_keyalg {
     const char *ssh_id;    /* string identifier in the SSH protocol */
     const char *cache_id;  /* identifier used in PuTTY's host key cache */
     const void *extra;     /* private to the public key methods */
-    /*WINSCP const*/ unsigned supported_flags;    /* signature-type flags we understand */
+    const unsigned supported_flags;    /* signature-type flags we understand */
 };
+#pragma option pop // WINSCP
 
 static inline ssh_key *ssh_key_new_pub(const ssh_keyalg *self, ptrlen pub)
 { return self->new_pub(self, pub); }

+ 7 - 6
source/putty/ssh1bpp.c

@@ -37,12 +37,13 @@ static void ssh1_bpp_queue_disconnect(BinaryPacketProtocol *bpp,
 static PktOut *ssh1_bpp_new_pktout(int type);
 
 static const BinaryPacketProtocolVtable ssh1_bpp_vtable = {
-    .free = ssh1_bpp_free,
-    .handle_input = ssh1_bpp_handle_input,
-    .handle_output = ssh1_bpp_handle_output,
-    .new_pktout = ssh1_bpp_new_pktout,
-    .queue_disconnect = ssh1_bpp_queue_disconnect,
-    .packet_size_limit = 0xFFFFFFFF, /* no special limit for this bpp */
+    // WINSCP
+    /*.free =*/ ssh1_bpp_free,
+    /*.handle_input =*/ ssh1_bpp_handle_input,
+    /*.handle_output =*/ ssh1_bpp_handle_output,
+    /*.new_pktout =*/ ssh1_bpp_new_pktout,
+    /*.queue_disconnect =*/ ssh1_bpp_queue_disconnect,
+    /*.packet_size_limit =*/ 0xFFFFFFFF, /* no special limit for this bpp */
 };
 
 BinaryPacketProtocol *ssh1_bpp_new(LogContext *logctx)

+ 17 - 13
source/putty/ssh1connection-client.c

@@ -171,6 +171,7 @@ bool ssh1_handle_direction_specific_packet(
              * agent and set up an ordinary port-forwarding type
              * channel over it.
              */
+            { // WINSCP
             Plug *plug;
             Channel *ch = portfwd_raw_new(&s->cl, &plug, true);
             Socket *skt = agent_connect(plug);
@@ -194,6 +195,7 @@ bool ssh1_handle_direction_specific_packet(
             put_uint32(pktout, c->remoteid);
             put_uint32(pktout, c->localid);
             pq_push(s->ppl.out_pq, pktout);
+            } // WINSCP
         }
 
         return true;
@@ -445,19 +447,21 @@ static void ssh1mainchan_write_eof(SshChannel *sc)
 }
 
 static const SshChannelVtable ssh1mainchan_vtable = {
-    .write = ssh1mainchan_write,
-    .write_eof = ssh1mainchan_write_eof,
-    .request_x11_forwarding = ssh1mainchan_request_x11_forwarding,
-    .request_agent_forwarding = ssh1mainchan_request_agent_forwarding,
-    .request_pty = ssh1mainchan_request_pty,
-    .send_env_var = ssh1mainchan_send_env_var,
-    .start_shell = ssh1mainchan_start_shell,
-    .start_command = ssh1mainchan_start_command,
-    .start_subsystem = ssh1mainchan_start_subsystem,
-    .send_serial_break = ssh1mainchan_send_serial_break,
-    .send_signal = ssh1mainchan_send_signal,
-    .send_terminal_size_change = ssh1mainchan_send_terminal_size_change,
-    .hint_channel_is_simple = ssh1mainchan_hint_channel_is_simple,
+    // WINSCP
+    /*.write =*/ ssh1mainchan_write,
+    /*.write_eof =*/ ssh1mainchan_write_eof,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, // WINSCP
+    /*.request_x11_forwarding =*/ ssh1mainchan_request_x11_forwarding,
+    /*.request_agent_forwarding =*/ ssh1mainchan_request_agent_forwarding,
+    /*.request_pty =*/ ssh1mainchan_request_pty,
+    /*.send_env_var =*/ ssh1mainchan_send_env_var,
+    /*.start_shell =*/ ssh1mainchan_start_shell,
+    /*.start_command =*/ ssh1mainchan_start_command,
+    /*.start_subsystem =*/ ssh1mainchan_start_subsystem,
+    /*.send_serial_break =*/ ssh1mainchan_send_serial_break,
+    /*.send_signal =*/ ssh1mainchan_send_signal,
+    /*.send_terminal_size_change =*/ ssh1mainchan_send_terminal_size_change,
+    /*.hint_channel_is_simple =*/ ssh1mainchan_hint_channel_is_simple,
     /* other methods are NULL */
 };
 

+ 36 - 31
source/putty/ssh1connection.c

@@ -40,15 +40,16 @@ static void ssh1_connection_reconfigure(PacketProtocolLayer *ppl, Conf *conf);
 static unsigned int ssh1_connection_winscp_query(PacketProtocolLayer *ppl, int query);
 
 static const PacketProtocolLayerVtable ssh1_connection_vtable = {
-    .free = ssh1_connection_free,
-    .process_queue = ssh1_connection_process_queue,
-    .get_specials = ssh1_common_get_specials,
-    .special_cmd = ssh1_connection_special_cmd,
-    .want_user_input = ssh1_connection_want_user_input,
-    .got_user_input = ssh1_connection_got_user_input,
-    .reconfigure = ssh1_connection_reconfigure,
-    .queued_data_size = ssh_ppl_default_queued_data_size,
-    .name = NULL, /* no layer names in SSH-1 */
+    // WINSCP
+    /*.free =*/ ssh1_connection_free,
+    /*.process_queue =*/ ssh1_connection_process_queue,
+    /*.get_specials =*/ ssh1_common_get_specials,
+    /*.special_cmd =*/ ssh1_connection_special_cmd,
+    /*.want_user_input =*/ ssh1_connection_want_user_input,
+    /*.got_user_input =*/ ssh1_connection_got_user_input,
+    /*.reconfigure =*/ ssh1_connection_reconfigure,
+    /*.queued_data_size =*/ ssh_ppl_default_queued_data_size,
+    /*.name =*/ NULL, /* no layer names in SSH-1 */
     ssh1_connection_winscp_query,
 };
 
@@ -70,22 +71,24 @@ static void ssh1_enable_x_fwd(ConnectionLayer *cl);
 static void ssh1_set_wants_user_input(ConnectionLayer *cl, bool wanted);
 
 static const ConnectionLayerVtable ssh1_connlayer_vtable = {
-    .rportfwd_alloc = ssh1_rportfwd_alloc,
-    .rportfwd_remove = ssh1_rportfwd_remove,
-    .lportfwd_open = ssh1_lportfwd_open,
-    .session_open = ssh1_session_open,
-    .serverside_x11_open = ssh1_serverside_x11_open,
-    .serverside_agent_open = ssh1_serverside_agent_open,
-    .add_x11_display = ssh1_add_x11_display,
-    .agent_forwarding_permitted = ssh1_agent_forwarding_permitted,
-    .terminal_size = ssh1_terminal_size,
-    .stdout_unthrottle = ssh1_stdout_unthrottle,
-    .stdin_backlog = ssh1_stdin_backlog,
-    .throttle_all_channels = ssh1_throttle_all_channels,
-    .ldisc_option = ssh1_ldisc_option,
-    .set_ldisc_option = ssh1_set_ldisc_option,
-    .enable_x_fwd = ssh1_enable_x_fwd,
-    .set_wants_user_input = ssh1_set_wants_user_input,
+    // WINSCP
+    /*.rportfwd_alloc =*/ ssh1_rportfwd_alloc,
+    /*.rportfwd_remove =*/ ssh1_rportfwd_remove,
+    /*.lportfwd_open =*/ ssh1_lportfwd_open,
+    /*.session_open =*/ ssh1_session_open,
+    /*.serverside_x11_open =*/ ssh1_serverside_x11_open,
+    /*.serverside_agent_open =*/ ssh1_serverside_agent_open,
+    /*.add_x11_display =*/ ssh1_add_x11_display,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, // WINSCP
+    /*.agent_forwarding_permitted =*/ ssh1_agent_forwarding_permitted,
+    /*.terminal_size =*/ ssh1_terminal_size,
+    /*.stdout_unthrottle =*/ ssh1_stdout_unthrottle,
+    /*.stdin_backlog =*/ ssh1_stdin_backlog,
+    /*.throttle_all_channels =*/ ssh1_throttle_all_channels,
+    /*.ldisc_option =*/ ssh1_ldisc_option,
+    /*.set_ldisc_option =*/ ssh1_set_ldisc_option,
+    /*.enable_x_fwd =*/ ssh1_enable_x_fwd,
+    /*.set_wants_user_input =*/ ssh1_set_wants_user_input,
     /* other methods are NULL */
 };
 
@@ -98,13 +101,15 @@ static Conf *ssh1channel_get_conf(SshChannel *c);
 static void ssh1channel_window_override_removed(SshChannel *c) { /* ignore */ }
 
 static const SshChannelVtable ssh1channel_vtable = {
-    .write = ssh1channel_write,
-    .write_eof = ssh1channel_write_eof,
-    .initiate_close = ssh1channel_initiate_close,
-    .unthrottle = ssh1channel_unthrottle,
-    .get_conf = ssh1channel_get_conf,
-    .window_override_removed = ssh1channel_window_override_removed,
+    // WINSCP
+    /*.write =*/ ssh1channel_write,
+    /*.write_eof =*/ ssh1channel_write_eof,
+    /*.initiate_close =*/ ssh1channel_initiate_close,
+    /*.unthrottle =*/ ssh1channel_unthrottle,
+    /*.get_conf =*/ ssh1channel_get_conf,
+    /*.window_override_removed =*/ ssh1channel_window_override_removed,
     /* everything else is NULL */
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, // WINSCP
 };
 
 static void ssh1_channel_try_eof(struct ssh1_channel *c);

+ 10 - 9
source/putty/ssh1login.c

@@ -80,15 +80,16 @@ static void ssh1_login_reconfigure(PacketProtocolLayer *ppl, Conf *conf);
 static unsigned int ssh1_login_winscp_query(PacketProtocolLayer *ppl, int query);
 
 static const PacketProtocolLayerVtable ssh1_login_vtable = {
-    .free = ssh1_login_free,
-    .process_queue = ssh1_login_process_queue,
-    .get_specials = ssh1_common_get_specials,
-    .special_cmd = ssh1_login_special_cmd,
-    .want_user_input = ssh1_login_want_user_input,
-    .got_user_input = ssh1_login_got_user_input,
-    .reconfigure = ssh1_login_reconfigure,
-    .queued_data_size = ssh_ppl_default_queued_data_size,
-    .name = NULL, /* no layer names in SSH-1 */
+    // WINSCP
+    /*.free =*/ ssh1_login_free,
+    /*.process_queue =*/ ssh1_login_process_queue,
+    /*.get_specials =*/ ssh1_common_get_specials,
+    /*.special_cmd =*/ ssh1_login_special_cmd,
+    /*.want_user_input =*/ ssh1_login_want_user_input,
+    /*.got_user_input =*/ ssh1_login_got_user_input,
+    /*.reconfigure =*/ ssh1_login_reconfigure,
+    /*.queued_data_size =*/ ssh_ppl_default_queued_data_size,
+    /*.name =*/ NULL, /* no layer names in SSH-1 */
     ssh1_login_winscp_query,
 };
 

+ 7 - 6
source/putty/ssh2bpp-bare.c

@@ -26,14 +26,15 @@ static void ssh2_bare_bpp_handle_output(BinaryPacketProtocol *bpp);
 static PktOut *ssh2_bare_bpp_new_pktout(int type);
 
 static const BinaryPacketProtocolVtable ssh2_bare_bpp_vtable = {
-    .free = ssh2_bare_bpp_free,
-    .handle_input = ssh2_bare_bpp_handle_input,
-    .handle_output = ssh2_bare_bpp_handle_output,
-    .new_pktout = ssh2_bare_bpp_new_pktout,
-    .queue_disconnect = ssh2_bpp_queue_disconnect, /* in sshcommon.c */
+    // WINSCP
+    /*.free =*/ ssh2_bare_bpp_free,
+    /*.handle_input =*/ ssh2_bare_bpp_handle_input,
+    /*.handle_output =*/ ssh2_bare_bpp_handle_output,
+    /*.new_pktout =*/ ssh2_bare_bpp_new_pktout,
+    /*.queue_disconnect =*/ ssh2_bpp_queue_disconnect, /* in sshcommon.c */
 
     /* packet size limit, per protocol spec in sshshare.c comment */
-    .packet_size_limit = 0x4000,
+    /*.packet_size_limit =*/ 0x4000,
 };
 
 BinaryPacketProtocol *ssh2_bare_bpp_new(LogContext *logctx)

+ 7 - 6
source/putty/ssh2bpp.c

@@ -50,12 +50,13 @@ static void ssh2_bpp_handle_output(BinaryPacketProtocol *bpp);
 static PktOut *ssh2_bpp_new_pktout(int type);
 
 static const BinaryPacketProtocolVtable ssh2_bpp_vtable = {
-    .free = ssh2_bpp_free,
-    .handle_input = ssh2_bpp_handle_input,
-    .handle_output = ssh2_bpp_handle_output,
-    .new_pktout = ssh2_bpp_new_pktout,
-    .queue_disconnect = ssh2_bpp_queue_disconnect, /* in sshcommon.c */
-    .packet_size_limit = 0xFFFFFFFF, /* no special limit for this bpp */
+    // WINSCP
+    /*.free =*/ ssh2_bpp_free,
+    /*.handle_input =*/ ssh2_bpp_handle_input,
+    /*.handle_output =*/ ssh2_bpp_handle_output,
+    /*.new_pktout =*/ ssh2_bpp_new_pktout,
+    /*.queue_disconnect =*/ ssh2_bpp_queue_disconnect, /* in sshcommon.c */
+    /*.packet_size_limit =*/ 0xFFFFFFFF, /* no special limit for this bpp */
 };
 
 BinaryPacketProtocol *ssh2_bpp_new(

+ 2 - 0
source/putty/ssh2connection-client.c

@@ -99,6 +99,7 @@ static ChanopenResult chan_open_auth_agent(
      * If possible, make a stream-oriented connection to the agent and
      * set up an ordinary port-forwarding type channel over it.
      */
+    { // WINSCP
     Plug *plug;
     Channel *ch = portfwd_raw_new(&s->cl, &plug, true);
     Socket *skt = agent_connect(plug);
@@ -115,6 +116,7 @@ static ChanopenResult chan_open_auth_agent(
          */
         CHANOPEN_RETURN_SUCCESS(agentf_new(sc));
     }
+    } // WINSCP
 }
 
 ChanopenResult ssh2_connection_parse_channel_open(

+ 58 - 53
source/putty/ssh2connection.c

@@ -26,15 +26,16 @@ static void ssh2_connection_reconfigure(PacketProtocolLayer *ppl, Conf *conf);
 static unsigned int ssh2_connection_winscp_query(PacketProtocolLayer *ppl, int query);
 
 static const PacketProtocolLayerVtable ssh2_connection_vtable = {
-    .free = ssh2_connection_free,
-    .process_queue = ssh2_connection_process_queue,
-    .get_specials = ssh2_connection_get_specials,
-    .special_cmd = ssh2_connection_special_cmd,
-    .want_user_input = ssh2_connection_want_user_input,
-    .got_user_input = ssh2_connection_got_user_input,
-    .reconfigure = ssh2_connection_reconfigure,
-    .queued_data_size = ssh_ppl_default_queued_data_size,
-    .name = "ssh-connection",
+    // WINSCP
+    /*.free =*/ ssh2_connection_free,
+    /*.process_queue =*/ ssh2_connection_process_queue,
+    /*.get_specials =*/ ssh2_connection_get_specials,
+    /*.special_cmd =*/ ssh2_connection_special_cmd,
+    /*.want_user_input =*/ ssh2_connection_want_user_input,
+    /*.got_user_input =*/ ssh2_connection_got_user_input,
+    /*.reconfigure =*/ ssh2_connection_reconfigure,
+    /*.queued_data_size =*/ ssh_ppl_default_queued_data_size,
+    /*.name =*/ "ssh-connection",
     ssh2_connection_winscp_query,
 };
 
@@ -69,29 +70,30 @@ static void ssh2_enable_x_fwd(ConnectionLayer *cl);
 static void ssh2_set_wants_user_input(ConnectionLayer *cl, bool wanted);
 
 static const ConnectionLayerVtable ssh2_connlayer_vtable = {
-    .rportfwd_alloc = ssh2_rportfwd_alloc,
-    .rportfwd_remove = ssh2_rportfwd_remove,
-    .lportfwd_open = ssh2_lportfwd_open,
-    .session_open = ssh2_session_open,
-    .serverside_x11_open = ssh2_serverside_x11_open,
-    .serverside_agent_open = ssh2_serverside_agent_open,
-    .add_x11_display = ssh2_add_x11_display,
-    .add_sharing_x11_display = ssh2_add_sharing_x11_display,
-    .remove_sharing_x11_display = ssh2_remove_sharing_x11_display,
-    .send_packet_from_downstream = ssh2_send_packet_from_downstream,
-    .alloc_sharing_channel = ssh2_alloc_sharing_channel,
-    .delete_sharing_channel = ssh2_delete_sharing_channel,
-    .sharing_queue_global_request = ssh2_sharing_queue_global_request,
-    .sharing_no_more_downstreams = ssh2_sharing_no_more_downstreams,
-    .agent_forwarding_permitted = ssh2_agent_forwarding_permitted,
-    .terminal_size = ssh2_terminal_size,
-    .stdout_unthrottle = ssh2_stdout_unthrottle,
-    .stdin_backlog = ssh2_stdin_backlog,
-    .throttle_all_channels = ssh2_throttle_all_channels,
-    .ldisc_option = ssh2_ldisc_option,
-    .set_ldisc_option = ssh2_set_ldisc_option,
-    .enable_x_fwd = ssh2_enable_x_fwd,
-    .set_wants_user_input = ssh2_set_wants_user_input,
+    // WINSCP
+    /*.rportfwd_alloc =*/ ssh2_rportfwd_alloc,
+    /*.rportfwd_remove =*/ ssh2_rportfwd_remove,
+    /*.lportfwd_open =*/ ssh2_lportfwd_open,
+    /*.session_open =*/ ssh2_session_open,
+    /*.serverside_x11_open =*/ ssh2_serverside_x11_open,
+    /*.serverside_agent_open =*/ ssh2_serverside_agent_open,
+    /*.add_x11_display =*/ ssh2_add_x11_display,
+    /*.add_sharing_x11_display =*/ ssh2_add_sharing_x11_display,
+    /*.remove_sharing_x11_display =*/ ssh2_remove_sharing_x11_display,
+    /*.send_packet_from_downstream =*/ ssh2_send_packet_from_downstream,
+    /*.alloc_sharing_channel =*/ ssh2_alloc_sharing_channel,
+    /*.delete_sharing_channel =*/ ssh2_delete_sharing_channel,
+    /*.sharing_queue_global_request =*/ ssh2_sharing_queue_global_request,
+    /*.sharing_no_more_downstreams =*/ ssh2_sharing_no_more_downstreams,
+    /*.agent_forwarding_permitted =*/ ssh2_agent_forwarding_permitted,
+    /*.terminal_size =*/ ssh2_terminal_size,
+    /*.stdout_unthrottle =*/ ssh2_stdout_unthrottle,
+    /*.stdin_backlog =*/ ssh2_stdin_backlog,
+    /*.throttle_all_channels =*/ ssh2_throttle_all_channels,
+    /*.ldisc_option =*/ ssh2_ldisc_option,
+    /*.set_ldisc_option =*/ ssh2_set_ldisc_option,
+    /*.enable_x_fwd =*/ ssh2_enable_x_fwd,
+    /*.set_wants_user_input =*/ ssh2_set_wants_user_input,
 };
 
 static char *ssh2_channel_open_failure_error_text(PktIn *pktin)
@@ -135,27 +137,28 @@ static void ssh2channel_x11_sharing_handover(
 static void ssh2channel_hint_channel_is_simple(SshChannel *c);
 
 static const SshChannelVtable ssh2channel_vtable = {
-    .write = ssh2channel_write,
-    .write_eof = ssh2channel_write_eof,
-    .initiate_close = ssh2channel_initiate_close,
-    .unthrottle = ssh2channel_unthrottle,
-    .get_conf = ssh2channel_get_conf,
-    .window_override_removed = ssh2channel_window_override_removed,
-    .x11_sharing_handover = ssh2channel_x11_sharing_handover,
-    .send_exit_status = ssh2channel_send_exit_status,
-    .send_exit_signal = ssh2channel_send_exit_signal,
-    .send_exit_signal_numeric = ssh2channel_send_exit_signal_numeric,
-    .request_x11_forwarding = ssh2channel_request_x11_forwarding,
-    .request_agent_forwarding = ssh2channel_request_agent_forwarding,
-    .request_pty = ssh2channel_request_pty,
-    .send_env_var = ssh2channel_send_env_var,
-    .start_shell = ssh2channel_start_shell,
-    .start_command = ssh2channel_start_command,
-    .start_subsystem = ssh2channel_start_subsystem,
-    .send_serial_break = ssh2channel_send_serial_break,
-    .send_signal = ssh2channel_send_signal,
-    .send_terminal_size_change = ssh2channel_send_terminal_size_change,
-    .hint_channel_is_simple = ssh2channel_hint_channel_is_simple,
+    // WINSCP
+    /*.write =*/ ssh2channel_write,
+    /*.write_eof =*/ ssh2channel_write_eof,
+    /*.initiate_close =*/ ssh2channel_initiate_close,
+    /*.unthrottle =*/ ssh2channel_unthrottle,
+    /*.get_conf =*/ ssh2channel_get_conf,
+    /*.window_override_removed =*/ ssh2channel_window_override_removed,
+    /*.x11_sharing_handover =*/ ssh2channel_x11_sharing_handover,
+    /*.send_exit_status =*/ ssh2channel_send_exit_status,
+    /*.send_exit_signal =*/ ssh2channel_send_exit_signal,
+    /*.send_exit_signal_numeric =*/ ssh2channel_send_exit_signal_numeric,
+    /*.request_x11_forwarding =*/ ssh2channel_request_x11_forwarding,
+    /*.request_agent_forwarding =*/ ssh2channel_request_agent_forwarding,
+    /*.request_pty =*/ ssh2channel_request_pty,
+    /*.send_env_var =*/ ssh2channel_send_env_var,
+    /*.start_shell =*/ ssh2channel_start_shell,
+    /*.start_command =*/ ssh2channel_start_command,
+    /*.start_subsystem =*/ ssh2channel_start_subsystem,
+    /*.send_serial_break =*/ ssh2channel_send_serial_break,
+    /*.send_signal =*/ ssh2channel_send_signal,
+    /*.send_terminal_size_change =*/ ssh2channel_send_terminal_size_change,
+    /*.hint_channel_is_simple =*/ ssh2channel_hint_channel_is_simple,
 };
 
 static void ssh2_channel_check_close(struct ssh2_channel *c);
@@ -525,9 +528,11 @@ static bool ssh2_connection_filter_queue(struct ssh2_connection_state *s)
               case SSH2_MSG_CHANNEL_OPEN_FAILURE: {
                 assert(c->halfopen);
 
+                { // WINSCP
                 char *err = ssh2_channel_open_failure_error_text(pktin);
                 chan_open_failed(c->chan, err);
                 sfree(err);
+                } // WINSCP
 
                 del234(s->channels, c);
                 ssh2_channel_free(c);

+ 11 - 1
source/putty/ssh2kex-client.c

@@ -783,6 +783,7 @@ void ssh2kex_coroutine(struct ssh2_transport_state *s, bool *aborted)
              * triggered on purpose to populate the transient cache.
              */
             assert(s->hkey);  /* only KEXTYPE_GSS lets this be null */
+            { // WINSCP
             char *fingerprint = ssh2_fingerprint(s->hkey, SSH_FPTYPE_DEFAULT);
 
             if (s->need_gss_transient_hostkey) {
@@ -802,6 +803,7 @@ void ssh2kex_coroutine(struct ssh2_transport_state *s, bool *aborted)
             }
 
             sfree(fingerprint);
+            } // WINSCP
         }
     } else
 #endif /* NO_GSSAPI */
@@ -847,6 +849,7 @@ void ssh2kex_coroutine(struct ssh2_transport_state *s, bool *aborted)
              * Authenticate remote host: verify host key. (We've already
              * checked the signature of the exchange hash.)
              */
+            { // WINSCP
             char **fingerprints = ssh2_all_fingerprints(s->hkey);
             FingerprintType fptype_default =
                 ssh2_pick_default_fingerprint(fingerprints);
@@ -862,7 +865,10 @@ void ssh2kex_coroutine(struct ssh2_transport_state *s, bool *aborted)
                 *aborted = true;
                 return;
             } else if (s->dlgret < 0) { /* none configured; use standard handling */
-                ssh2_userkey uk = { .key = s->hkey, .comment = NULL };
+                ssh2_userkey uk; // WINSCP
+                uk.key = s->hkey; // WINSCP
+                uk.comment = NULL; // WINSCP
+                { // WINSCP
                 char *keydisp = ssh2_pubkey_openssh_str(&uk);
                 s->dlgret = seat_verify_ssh_host_key(
                     s->ppl.seat, s->savedhost, s->savedport,
@@ -880,6 +886,7 @@ void ssh2kex_coroutine(struct ssh2_transport_state *s, bool *aborted)
                     *aborted = true;
                     return;
                 }
+                } // WINSCP
             }
 
             /*
@@ -888,10 +895,12 @@ void ssh2kex_coroutine(struct ssh2_transport_state *s, bool *aborted)
              */
             s->hostkey_str = s->keystr;
             s->keystr = NULL;
+            } // WINSCP
         } else if (s->cross_certifying) {
             assert(s->hkey);
             assert(ssh_key_alg(s->hkey) == s->cross_certifying);
 
+            { // WINSCP
             char *fingerprint = ssh2_fingerprint(s->hkey, SSH_FPTYPE_DEFAULT);
             ppl_logevent("Storing additional host key for this host:");
             ppl_logevent("%s", fingerprint);
@@ -905,6 +914,7 @@ void ssh2kex_coroutine(struct ssh2_transport_state *s, bool *aborted)
              */
             s->hostkey_str = s->keystr;
             s->keystr = NULL;
+            } // WINSCP
         } else {
             /*
              * In a rekey, we never present an interactive host key

+ 28 - 21
source/putty/ssh2transport.c

@@ -55,15 +55,16 @@ static bool ssh_decomp_none_block(ssh_decompressor *handle,
     return false;
 }
 static const ssh_compression_alg ssh_comp_none = {
-    .name = "none",
-    .delayed_name = NULL,
-    .compress_new = ssh_comp_none_init,
-    .compress_free = ssh_comp_none_cleanup,
-    .compress = ssh_comp_none_block,
-    .decompress_new = ssh_decomp_none_init,
-    .decompress_free = ssh_decomp_none_cleanup,
-    .decompress = ssh_decomp_none_block,
-    .text_name = NULL,
+    // WINSCP
+    /*.name =*/ "none",
+    /*.delayed_name =*/ NULL,
+    /*.compress_new =*/ ssh_comp_none_init,
+    /*.compress_free =*/ ssh_comp_none_cleanup,
+    /*.compress =*/ ssh_comp_none_block,
+    /*.decompress_new =*/ ssh_decomp_none_init,
+    /*.decompress_free =*/ ssh_decomp_none_cleanup,
+    /*.decompress =*/ ssh_decomp_none_block,
+    /*.text_name =*/ NULL,
 };
 const static ssh_compression_alg *const compressions[] = {
     &ssh_zlib, &ssh_comp_none
@@ -86,15 +87,16 @@ static void ssh2_transport_higher_layer_packet_callback(void *context);
 static unsigned int ssh2_transport_winscp_query(PacketProtocolLayer *ppl, int query);
 
 static const PacketProtocolLayerVtable ssh2_transport_vtable = {
-    .free = ssh2_transport_free,
-    .process_queue = ssh2_transport_process_queue,
-    .get_specials = ssh2_transport_get_specials,
-    .special_cmd = ssh2_transport_special_cmd,
-    .want_user_input = ssh2_transport_want_user_input,
-    .got_user_input = ssh2_transport_got_user_input,
-    .reconfigure = ssh2_transport_reconfigure,
-    .queued_data_size = ssh2_transport_queued_data_size,
-    .name = NULL, /* no protocol name for this layer */
+    // WINSCP
+    /*.free =*/ ssh2_transport_free,
+    /*.process_queue =*/ ssh2_transport_process_queue,
+    /*.get_specials =*/ ssh2_transport_get_specials,
+    /*.special_cmd =*/ ssh2_transport_special_cmd,
+    /*.want_user_input =*/ ssh2_transport_want_user_input,
+    /*.got_user_input =*/ ssh2_transport_got_user_input,
+    /*.reconfigure =*/ ssh2_transport_reconfigure,
+    /*.queued_data_size =*/ ssh2_transport_queued_data_size,
+    /*.name =*/ NULL, /* no protocol name for this layer */
     ssh2_transport_winscp_query,
 };
 
@@ -405,7 +407,8 @@ bool ssh2_common_filter_queue(PacketProtocolLayer *ppl)
              * the session before the BPP aborts it anyway.
              */
             uint32_t nexts = get_uint32(pktin);
-            for (uint32_t i = 0; i < nexts && !get_err(pktin); i++) {
+            uint32_t i; // WINSCP
+            for (i = 0; i < nexts && !get_err(pktin); i++) {
                 ptrlen extname = get_string(pktin);
                 ptrlen extvalue = get_string(pktin);
                 if (ptrlen_eq_string(extname, "server-sig-algs")) {
@@ -1076,7 +1079,8 @@ static bool ssh2_scan_kexinits(
              PTRLEN_LITERAL("ext-info-s"));
         ptrlen list = (server_hostkeys ? clists[KEXLIST_KEX] :
                        slists[KEXLIST_KEX]);
-        for (ptrlen word; get_commasep_word(&list, &word) ;)
+        ptrlen word; // WINSCP
+        for (; get_commasep_word(&list, &word) ;)
             if (ptrlen_eq_ptrlen(word, extinfo_advert))
                 *can_send_ext_info = true;
     }
@@ -1469,10 +1473,13 @@ static void ssh2_transport_process_queue(PacketProtocolLayer *ppl)
                  * key algorithms. */
                 n_exts++;
                 put_stringz(extinfo, "server-sig-algs");
+                { // WINSCP
                 strbuf *list = strbuf_new();
-                for (size_t i = 0; i < n_keyalgs; i++)
+                size_t i; // WINSCP
+                for (i = 0; i < n_keyalgs; i++)
                     add_to_commasep(list, all_keyalgs[i]->ssh_id);
                 put_stringsb(extinfo, list);
+                }  // WINSCP
             } else {
                 /* Client->server EXT_INFO is currently not sent, but here's
                  * where we should put things in it if we ever want to. */

+ 11 - 9
source/putty/ssh2userauth.c

@@ -122,15 +122,17 @@ static void ssh2_userauth_antispoof_msg(
     struct ssh2_userauth_state *s, const char *msg);
 
 static const PacketProtocolLayerVtable ssh2_userauth_vtable = {
-    .free = ssh2_userauth_free,
-    .process_queue = ssh2_userauth_process_queue,
-    .get_specials = ssh2_userauth_get_specials,
-    .special_cmd = ssh2_userauth_special_cmd,
-    .want_user_input = ssh2_userauth_want_user_input,
-    .got_user_input = ssh2_userauth_got_user_input,
-    .reconfigure = ssh2_userauth_reconfigure,
-    .queued_data_size = ssh_ppl_default_queued_data_size,
-    .name = "ssh-userauth",
+    // WINSCP
+    /*.free =*/ ssh2_userauth_free,
+    /*.process_queue =*/ ssh2_userauth_process_queue,
+    /*.get_specials =*/ ssh2_userauth_get_specials,
+    /*.special_cmd =*/ ssh2_userauth_special_cmd,
+    /*.want_user_input =*/ ssh2_userauth_want_user_input,
+    /*.got_user_input =*/ ssh2_userauth_got_user_input,
+    /*.reconfigure =*/ ssh2_userauth_reconfigure,
+    /*.queued_data_size =*/ ssh_ppl_default_queued_data_size,
+    /*.name =*/ "ssh-userauth",
+    NULL, // WINSCP
 };
 
 PacketProtocolLayer *ssh2_userauth_new(

+ 52 - 40
source/putty/sshaes.c

@@ -113,49 +113,58 @@ struct aes_extra {
     /*WINSCP static*/ void cid##_sw##encsuffix(ssh_cipher *, void *blk, int len);  \
     /*WINSCP static*/ void cid##_sw##decsuffix(ssh_cipher *, void *blk, int len);  \
     const ssh_cipheralg ssh_##cid##_sw = {                              \
-        .new = aes_sw_new,                                              \
-        .free = aes_sw_free,                                            \
-        .setiv = aes_sw_##setivsuffix,                                  \
-        .setkey = aes_sw_setkey,                                        \
-        .encrypt = cid##_sw##encsuffix,                                 \
-        .decrypt = cid##_sw##decsuffix,                                 \
-        .ssh2_id = pid,                                                 \
-        .blksize = 16,                                                  \
-        .real_keybits = bits,                                           \
-        .padded_keybytes = bits/8,                                      \
-        .flags = flagsval,                                              \
-        .text_name = name " (unaccelerated)",                           \
+        /*WINSCP*/                                                          \
+        /*.new =*/ aes_sw_new,                                              \
+        /*.free =*/ aes_sw_free,                                            \
+        /*.setiv =*/ aes_sw_##setivsuffix,                                  \
+        /*.setkey =*/ aes_sw_setkey,                                        \
+        /*.encrypt =*/ cid##_sw##encsuffix,                                 \
+        /*.decrypt =*/ cid##_sw##decsuffix,                                 \
+        NULL, NULL, /*WINSCP*/                                              \
+        /*.ssh2_id =*/ pid,                                                 \
+        /*.blksize =*/ 16,                                                  \
+        /*.real_keybits =*/ bits,                                           \
+        /*.padded_keybytes =*/ bits/8,                                      \
+        /*.flags =*/ flagsval,                                              \
+        /*.text_name =*/ name " (unaccelerated)",                           \
+        NULL, NULL, /*WINSCP*/                                              \
     };                                                                  \
                                                                         \
     /*WINSCP static*/ void cid##_hw##encsuffix(ssh_cipher *, void *blk, int len);  \
     /*WINSCP static*/ void cid##_hw##decsuffix(ssh_cipher *, void *blk, int len);  \
     const ssh_cipheralg ssh_##cid##_hw = {                              \
-        .new = aes_hw_new,                                              \
-        .free = aes_hw_free,                                            \
-        .setiv = aes_hw_##setivsuffix,                                  \
-        .setkey = aes_hw_setkey,                                        \
-        .encrypt = cid##_hw##encsuffix,                                 \
-        .decrypt = cid##_hw##decsuffix,                                 \
-        .ssh2_id = pid,                                                 \
-        .blksize = 16,                                                  \
-        .real_keybits = bits,                                           \
-        .padded_keybytes = bits/8,                                      \
-        .flags = flagsval,                                              \
-        .text_name = name HW_NAME_SUFFIX,                               \
+        /*WINSCP*/                                                          \
+        /*.new =*/ aes_hw_new,                                              \
+        /*.free =*/ aes_hw_free,                                            \
+        /*.setiv =*/ aes_hw_##setivsuffix,                                  \
+        /*.setkey =*/ aes_hw_setkey,                                        \
+        /*.encrypt =*/ cid##_hw##encsuffix,                                 \
+        /*.decrypt =*/ cid##_hw##decsuffix,                                 \
+        NULL, NULL, /*WINSCP*/                                              \
+        /*.ssh2_id =*/ pid,                                                 \
+        /*.blksize =*/ 16,                                                  \
+        /*.real_keybits =*/ bits,                                           \
+        /*.padded_keybytes =*/ bits/8,                                      \
+        /*.flags =*/ flagsval,                                              \
+        /*.text_name =*/ name HW_NAME_SUFFIX,                               \
+        NULL, NULL, /*WINSCP*/                                              \
     };                                                                  \
                                                                         \
     static const struct aes_extra extra_##cid = {                       \
         &ssh_##cid##_sw, &ssh_##cid##_hw };                             \
                                                                         \
     const ssh_cipheralg ssh_##cid = {                                   \
-        .new = aes_select,                                              \
-        .ssh2_id = pid,                                                 \
-        .blksize = 16,                                                  \
-        .real_keybits = bits,                                           \
-        .padded_keybytes = bits/8,                                      \
-        .flags = flagsval,                                              \
-        .text_name = name " (dummy selector vtable)",                   \
-        .extra = &extra_##cid                                           \
+        /*WINSCP*/                                                          \
+        /*.new =*/ aes_select,                                              \
+        NULL, NULL, NULL, NULL, NULL, NULL, NULL,                           \
+        /*.ssh2_id =*/ pid,                                                 \
+        /*.blksize =*/ 16,                                                  \
+        /*.real_keybits =*/ bits,                                           \
+        /*.padded_keybytes =*/ bits/8,                                      \
+        /*.flags =*/ flagsval,                                              \
+        /*.text_name =*/ name " (dummy selector vtable)",                   \
+        NULL,                                                               \
+        /*.extra =*/ &extra_##cid                                           \
     };                                                                  \
 
 #define VTABLES(keylen)                                                 \
@@ -171,14 +180,17 @@ VTABLES(256)
 
 static const ssh_cipheralg ssh_rijndael_lysator = {
     /* Same as aes256_cbc, but with a different protocol ID */
-    .new = aes_select,
-    .ssh2_id = "[email protected]",
-    .blksize = 16,
-    .real_keybits = 256,
-    .padded_keybytes = 256/8,
-    .flags = 0,
-    .text_name = "AES-256 CBC (dummy selector vtable)",
-    .extra = &extra_aes256_cbc,
+    // WINSCP
+    /*.new =*/ aes_select,
+    NULL, NULL, NULL, NULL, NULL, NULL, NULL, // WINSCP
+    /*.ssh2_id =*/ "[email protected]",
+    /*.blksize =*/ 16,
+    /*.real_keybits =*/ 256,
+    /*.padded_keybytes =*/ 256/8,
+    /*.flags =*/ 0,
+    /*.text_name =*/ "AES-256 CBC (dummy selector vtable)",
+    NULL, // WINSCP
+    /*.extra =*/ &extra_aes256_cbc,
 };
 
 static const ssh_cipheralg *const aes_list[] = {

+ 30 - 24
source/putty/ssharcf.c

@@ -104,33 +104,39 @@ static void arcfour_ssh2_block(ssh_cipher *cipher, void *blk, int len)
 }
 
 const ssh_cipheralg ssh_arcfour128_ssh2 = {
-    .new = arcfour_new,
-    .free = arcfour_free,
-    .setiv = arcfour_ssh2_setiv,
-    .setkey = arcfour_ssh2_setkey,
-    .encrypt = arcfour_ssh2_block,
-    .decrypt = arcfour_ssh2_block,
-    .ssh2_id = "arcfour128",
-    .blksize = 1,
-    .real_keybits = 128,
-    .padded_keybytes = 16,
-    .flags = 0,
-    .text_name = "Arcfour-128",
+    // WINSCP
+    /*.new =*/ arcfour_new,
+    /*.free =*/ arcfour_free,
+    /*.setiv =*/ arcfour_ssh2_setiv,
+    /*.setkey =*/ arcfour_ssh2_setkey,
+    /*.encrypt =*/ arcfour_ssh2_block,
+    /*.decrypt =*/ arcfour_ssh2_block,
+    NULL, NULL, // WINSCP
+    /*.ssh2_id =*/ "arcfour128",
+    /*.blksize =*/ 1,
+    /*.real_keybits =*/ 128,
+    /*.padded_keybytes =*/ 16,
+    /*.flags =*/ 0,
+    /*.text_name =*/ "Arcfour-128",
+    NULL, NULL, // WINSCP
 };
 
 const ssh_cipheralg ssh_arcfour256_ssh2 = {
-    .new = arcfour_new,
-    .free = arcfour_free,
-    .setiv = arcfour_ssh2_setiv,
-    .setkey = arcfour_ssh2_setkey,
-    .encrypt = arcfour_ssh2_block,
-    .decrypt = arcfour_ssh2_block,
-    .ssh2_id = "arcfour256",
-    .blksize = 1,
-    .real_keybits = 256,
-    .padded_keybytes = 32,
-    .flags = 0,
-    .text_name = "Arcfour-256",
+    // WINSCP
+    /*.new =*/ arcfour_new,
+    /*.free =*/ arcfour_free,
+    /*.setiv =*/ arcfour_ssh2_setiv,
+    /*.setkey =*/ arcfour_ssh2_setkey,
+    /*.encrypt =*/ arcfour_ssh2_block,
+    /*.decrypt =*/ arcfour_ssh2_block,
+    NULL, NULL, // WINSCP
+    /*.ssh2_id =*/ "arcfour256",
+    /*.blksize =*/ 1,
+    /*.real_keybits =*/ 256,
+    /*.padded_keybytes =*/ 32,
+    /*.flags =*/ 0,
+    /*.text_name =*/ "Arcfour-256",
+    NULL, NULL, // WINSCP
 };
 
 static const ssh_cipheralg *const arcfour_list[] = {

+ 44 - 35
source/putty/sshblowf.c

@@ -648,47 +648,56 @@ static void blowfish_ssh2_sdctr(ssh_cipher *cipher, void *blk, int len)
 }
 
 const ssh_cipheralg ssh_blowfish_ssh1 = {
-    .new = blowfish_new,
-    .free = blowfish_free,
-    .setiv = blowfish_ssh1_setiv,
-    .setkey = blowfish_ssh_setkey,
-    .encrypt = blowfish_ssh1_encrypt_blk,
-    .decrypt = blowfish_ssh1_decrypt_blk,
-    .blksize = 8,
-    .real_keybits = 128,
-    .padded_keybytes = SSH1_SESSION_KEY_LENGTH,
-    .flags = SSH_CIPHER_IS_CBC,
-    .text_name = "Blowfish-256 CBC",
+    // WINSCP
+    /*.new =*/ blowfish_new,
+    /*.free =*/ blowfish_free,
+    /*.setiv =*/ blowfish_ssh1_setiv,
+    /*.setkey =*/ blowfish_ssh_setkey,
+    /*.encrypt =*/ blowfish_ssh1_encrypt_blk,
+    /*.decrypt =*/ blowfish_ssh1_decrypt_blk,
+    NULL, NULL, NULL, // WINSCP
+    /*.blksize =*/ 8,
+    /*.real_keybits =*/ 128,
+    /*.padded_keybytes =*/ SSH1_SESSION_KEY_LENGTH,
+    /*.flags =*/ SSH_CIPHER_IS_CBC,
+    /*.text_name =*/ "Blowfish-256 CBC",
+    NULL, NULL, // WINSCP
 };
 
 const ssh_cipheralg ssh_blowfish_ssh2 = {
-    .new = blowfish_new,
-    .free = blowfish_free,
-    .setiv = blowfish_ssh2_setiv,
-    .setkey = blowfish_ssh_setkey,
-    .encrypt = blowfish_ssh2_encrypt_blk,
-    .decrypt = blowfish_ssh2_decrypt_blk,
-    .ssh2_id = "blowfish-cbc",
-    .blksize = 8,
-    .real_keybits = 128,
-    .padded_keybytes = 16,
-    .flags = SSH_CIPHER_IS_CBC,
-    .text_name = "Blowfish-128 CBC",
+    // WINSCP
+    /*.new =*/ blowfish_new,
+    /*.free =*/ blowfish_free,
+    /*.setiv =*/ blowfish_ssh2_setiv,
+    /*.setkey =*/ blowfish_ssh_setkey,
+    /*.encrypt =*/ blowfish_ssh2_encrypt_blk,
+    /*.decrypt =*/ blowfish_ssh2_decrypt_blk,
+    NULL, NULL, // WINSCP
+    /*.ssh2_id =*/ "blowfish-cbc",
+    /*.blksize =*/ 8,
+    /*.real_keybits =*/ 128,
+    /*.padded_keybytes =*/ 16,
+    /*.flags =*/ SSH_CIPHER_IS_CBC,
+    /*.text_name =*/ "Blowfish-128 CBC",
+    NULL, NULL, // WINSCP
 };
 
 const ssh_cipheralg ssh_blowfish_ssh2_ctr = {
-    .new = blowfish_new,
-    .free = blowfish_free,
-    .setiv = blowfish_ssh2_setiv,
-    .setkey = blowfish_ssh_setkey,
-    .encrypt = blowfish_ssh2_sdctr,
-    .decrypt = blowfish_ssh2_sdctr,
-    .ssh2_id = "blowfish-ctr",
-    .blksize = 8,
-    .real_keybits = 256,
-    .padded_keybytes = 32,
-    .flags = 0,
-    .text_name = "Blowfish-256 SDCTR",
+    // WINSCP
+    /*.new =*/ blowfish_new,
+    /*.free =*/ blowfish_free,
+    /*.setiv =*/ blowfish_ssh2_setiv,
+    /*.setkey =*/ blowfish_ssh_setkey,
+    /*.encrypt =*/ blowfish_ssh2_sdctr,
+    /*.decrypt =*/ blowfish_ssh2_sdctr,
+    NULL, NULL, // WINSCP
+    /*.ssh2_id =*/ "blowfish-ctr",
+    /*.blksize =*/ 8,
+    /*.real_keybits =*/ 256,
+    /*.padded_keybytes =*/ 32,
+    /*.flags =*/ 0,
+    /*.text_name =*/ "Blowfish-256 SDCTR",
+    NULL, NULL, // WINSCP
 };
 
 static const ssh_cipheralg *const blowfish_list[] = {

+ 29 - 25
source/putty/sshccp.c

@@ -944,17 +944,19 @@ static const char *poly_text_name(ssh2_mac *mac)
 }
 
 const ssh2_macalg ssh2_poly1305 = {
-    .new = poly_ssh2_new,
-    .free = poly_ssh2_free,
-    .setkey = poly_setkey,
-    .start = poly_start,
-    .genresult = poly_genresult,
-    .text_name = poly_text_name,
-    .name = "",
-    .etm_name = "", /* Not selectable individually, just part of
+    // WINSCP
+    /*.new =*/ poly_ssh2_new,
+    /*.free =*/ poly_ssh2_free,
+    /*.setkey =*/ poly_setkey,
+    /*.start =*/ poly_start,
+    /*.genresult =*/ poly_genresult,
+    /*.text_name =*/ poly_text_name,
+    /*.name =*/ "",
+    /*.etm_name =*/ "", /* Not selectable individually, just part of
                      * ChaCha20-Poly1305 */
-    .len = 16,
-    .keylen = 0,
+    /*.len =*/ 16,
+    /*.keylen =*/ 0,
+    NULL, // WINSCP
 };
 
 static ssh_cipher *ccp_new(const ssh_cipheralg *alg)
@@ -1038,21 +1040,23 @@ static void ccp_decrypt_length(ssh_cipher *cipher, void *blk, int len,
 }
 
 const ssh_cipheralg ssh2_chacha20_poly1305 = {
-    .new = ccp_new,
-    .free = ccp_free,
-    .setiv = ccp_iv,
-    .setkey = ccp_key,
-    .encrypt = ccp_encrypt,
-    .decrypt = ccp_decrypt,
-    .encrypt_length = ccp_encrypt_length,
-    .decrypt_length = ccp_decrypt_length,
-    .ssh2_id = "[email protected]",
-    .blksize = 1,
-    .real_keybits = 512,
-    .padded_keybytes = 64,
-    .flags = SSH_CIPHER_SEPARATE_LENGTH,
-    .text_name = "ChaCha20",
-    .required_mac = &ssh2_poly1305,
+    // WINSCP
+    /*.new =*/ ccp_new,
+    /*.free =*/ ccp_free,
+    /*.setiv =*/ ccp_iv,
+    /*.setkey =*/ ccp_key,
+    /*.encrypt =*/ ccp_encrypt,
+    /*.decrypt =*/ ccp_decrypt,
+    /*.encrypt_length =*/ ccp_encrypt_length,
+    /*.decrypt_length =*/ ccp_decrypt_length,
+    /*.ssh2_id =*/ "[email protected]",
+    /*.blksize =*/ 1,
+    /*.real_keybits =*/ 512,
+    /*.padded_keybytes =*/ 64,
+    /*.flags =*/ SSH_CIPHER_SEPARATE_LENGTH,
+    /*.text_name =*/ "ChaCha20",
+    /*.required_mac =*/ &ssh2_poly1305,
+    NULL, // WINSCP
 };
 
 static const ssh_cipheralg *const ccp_list[] = {

+ 26 - 23
source/putty/sshcommon.c

@@ -316,28 +316,28 @@ static bool zombiechan_want_close(Channel *chan, bool sent_eof, bool rcvd_eof);
 static char *zombiechan_log_close_msg(Channel *chan) { return NULL; }
 
 static const ChannelVtable zombiechan_channelvt = {
-    .free = zombiechan_free,
-    .open_confirmation = zombiechan_do_nothing,
-    .open_failed = zombiechan_open_failure,
-    .send = zombiechan_send,
-    .send_eof = zombiechan_do_nothing,
-    .set_input_wanted = zombiechan_set_input_wanted,
-    .log_close_msg = zombiechan_log_close_msg,
-    .want_close = zombiechan_want_close,
-    .rcvd_exit_status = chan_no_exit_status,
-    .rcvd_exit_signal = chan_no_exit_signal,
-    .rcvd_exit_signal_numeric = chan_no_exit_signal_numeric,
-    .run_shell = chan_no_run_shell,
-    .run_command = chan_no_run_command,
-    .run_subsystem = chan_no_run_subsystem,
-    .enable_x11_forwarding = chan_no_enable_x11_forwarding,
-    .enable_agent_forwarding = chan_no_enable_agent_forwarding,
-    .allocate_pty = chan_no_allocate_pty,
-    .set_env = chan_no_set_env,
-    .send_break = chan_no_send_break,
-    .send_signal = chan_no_send_signal,
-    .change_window_size = chan_no_change_window_size,
-    .request_response = chan_no_request_response,
+    /*.free =*/ zombiechan_free,
+    /*.open_confirmation =*/ zombiechan_do_nothing,
+    /*.open_failed =*/ zombiechan_open_failure,
+    /*.send =*/ zombiechan_send,
+    /*.send_eof =*/ zombiechan_do_nothing,
+    /*.set_input_wanted =*/ zombiechan_set_input_wanted,
+    /*.log_close_msg =*/ zombiechan_log_close_msg,
+    /*.want_close =*/ zombiechan_want_close,
+    /*.rcvd_exit_status =*/ chan_no_exit_status,
+    /*.rcvd_exit_signal =*/ chan_no_exit_signal,
+    /*.rcvd_exit_signal_numeric =*/ chan_no_exit_signal_numeric,
+    /*.run_shell =*/ chan_no_run_shell,
+    /*.run_command =*/ chan_no_run_command,
+    /*.run_subsystem =*/ chan_no_run_subsystem,
+    /*.enable_x11_forwarding =*/ chan_no_enable_x11_forwarding,
+    /*.enable_agent_forwarding =*/ chan_no_enable_agent_forwarding,
+    /*.allocate_pty =*/ chan_no_allocate_pty,
+    /*.set_env =*/ chan_no_set_env,
+    /*.send_break =*/ chan_no_send_break,
+    /*.send_signal =*/ chan_no_send_signal,
+    /*.change_window_size =*/ chan_no_change_window_size,
+    /*.request_response =*/ chan_no_request_response,
 };
 
 Channel *zombiechan_new(void)
@@ -864,7 +864,8 @@ int verify_ssh_manual_host_key(Conf *conf, char **fingerprints, ssh_key *key)
         return -1;                     /* no manual keys configured */
 
     if (fingerprints) {
-        for (size_t i = 0; i < SSH_N_FPTYPES; i++) {
+        size_t i; // WINSCP
+        for (i = 0; i < SSH_N_FPTYPES; i++) {
             /*
              * Each fingerprint string we've been given will have
              * things like 'ssh-rsa 2048' at the front of it. Strip
@@ -874,11 +875,13 @@ int verify_ssh_manual_host_key(Conf *conf, char **fingerprints, ssh_key *key)
             const char *fingerprint = fingerprints[i];
             if (!fingerprint)
                 continue;
+            { // WINSCP
             const char *p = strrchr(fingerprint, ' ');
             fingerprint = p ? p+1 : fingerprint;
             if (conf_get_str_str_opt(conf, CONF_ssh_manual_hostkeys,
                                      fingerprint))
                 return 1;                  /* success */
+            } // WINSCP
         }
     }
 

+ 75 - 59
source/putty/sshdes.c

@@ -691,34 +691,40 @@ static void des_cbc_decrypt(ssh_cipher *ciph, void *vdata, int len)
 }
 
 const ssh_cipheralg ssh_des = {
-    .new = des_cbc_new,
-    .free = des_cbc_free,
-    .setiv = des_cbc_setiv,
-    .setkey = des_cbc_setkey,
-    .encrypt = des_cbc_encrypt,
-    .decrypt = des_cbc_decrypt,
-    .ssh2_id = "des-cbc",
-    .blksize = 8,
-    .real_keybits = 56,
-    .padded_keybytes = 8,
-    .flags = SSH_CIPHER_IS_CBC,
-    .text_name = "single-DES CBC",
+    // WINSCP
+    /*.new =*/ des_cbc_new,
+    /*.free =*/ des_cbc_free,
+    /*.setiv =*/ des_cbc_setiv,
+    /*.setkey =*/ des_cbc_setkey,
+    /*.encrypt =*/ des_cbc_encrypt,
+    /*.decrypt =*/ des_cbc_decrypt,
+    NULL, NULL, // WINSCP
+    /*.ssh2_id =*/ "des-cbc",
+    /*.blksize =*/ 8,
+    /*.real_keybits =*/ 56,
+    /*.padded_keybytes =*/ 8,
+    /*.flags =*/ SSH_CIPHER_IS_CBC,
+    /*.text_name =*/ "single-DES CBC",
+    NULL, NULL, // WINSCP
 };
 
 const ssh_cipheralg ssh_des_sshcom_ssh2 = {
     /* Same as ssh_des_cbc, but with a different SSH-2 ID */
-    .new = des_cbc_new,
-    .free = des_cbc_free,
-    .setiv = des_cbc_setiv,
-    .setkey = des_cbc_setkey,
-    .encrypt = des_cbc_encrypt,
-    .decrypt = des_cbc_decrypt,
-    .ssh2_id = "[email protected]",
-    .blksize = 8,
-    .real_keybits = 56,
-    .padded_keybytes = 8,
-    .flags = SSH_CIPHER_IS_CBC,
-    .text_name = "single-DES CBC",
+    // WINSCP
+    /*.new =*/ des_cbc_new,
+    /*.free =*/ des_cbc_free,
+    /*.setiv =*/ des_cbc_setiv,
+    /*.setkey =*/ des_cbc_setkey,
+    /*.encrypt =*/ des_cbc_encrypt,
+    /*.decrypt =*/ des_cbc_decrypt,
+    NULL, NULL, // WINSCP
+    /*.ssh2_id =*/ "[email protected]",
+    /*.blksize =*/ 8,
+    /*.real_keybits =*/ 56,
+    /*.padded_keybytes =*/ 8,
+    /*.flags =*/ SSH_CIPHER_IS_CBC,
+    /*.text_name =*/ "single-DES CBC",
+    NULL, NULL, // WINSCP
 };
 
 static const ssh_cipheralg *const des_list[] = {
@@ -815,18 +821,21 @@ static void des3_cbc1_cbc_decrypt(ssh_cipher *ciph, void *vdata, int len)
 }
 
 const ssh_cipheralg ssh_3des_ssh2 = {
-    .new = des3_cbc1_new,
-    .free = des3_cbc1_free,
-    .setiv = des3_cbc1_setiv,
-    .setkey = des3_cbc1_setkey,
-    .encrypt = des3_cbc1_cbc_encrypt,
-    .decrypt = des3_cbc1_cbc_decrypt,
-    .ssh2_id = "3des-cbc",
-    .blksize = 8,
-    .real_keybits = 168,
-    .padded_keybytes = 24,
-    .flags = SSH_CIPHER_IS_CBC,
-    .text_name = "triple-DES CBC",
+    // WINSCP
+    /*.new =*/ des3_cbc1_new,
+    /*.free =*/ des3_cbc1_free,
+    /*.setiv =*/ des3_cbc1_setiv,
+    /*.setkey =*/ des3_cbc1_setkey,
+    /*.encrypt =*/ des3_cbc1_cbc_encrypt,
+    /*.decrypt =*/ des3_cbc1_cbc_decrypt,
+    NULL, NULL, // WINSCP
+    /*.ssh2_id =*/ "3des-cbc",
+    /*.blksize =*/ 8,
+    /*.real_keybits =*/ 168,
+    /*.padded_keybytes =*/ 24,
+    /*.flags =*/ SSH_CIPHER_IS_CBC,
+    /*.text_name =*/ "triple-DES CBC",
+    NULL, NULL, // WINSCP
 };
 
 /* ----------------------------------------------------------------------
@@ -921,18 +930,21 @@ static void des3_sdctr_encrypt_decrypt(ssh_cipher *ciph, void *vdata, int len)
 }
 
 const ssh_cipheralg ssh_3des_ssh2_ctr = {
-    .new = des3_sdctr_new,
-    .free = des3_sdctr_free,
-    .setiv = des3_sdctr_setiv,
-    .setkey = des3_sdctr_setkey,
-    .encrypt = des3_sdctr_encrypt_decrypt,
-    .decrypt = des3_sdctr_encrypt_decrypt,
-    .ssh2_id = "3des-ctr",
-    .blksize = 8,
-    .real_keybits = 168,
-    .padded_keybytes = 24,
-    .flags = 0,
-    .text_name = "triple-DES SDCTR",
+    // WINSCP
+    /*.new =*/ des3_sdctr_new,
+    /*.free =*/ des3_sdctr_free,
+    /*.setiv =*/ des3_sdctr_setiv,
+    /*.setkey =*/ des3_sdctr_setkey,
+    /*.encrypt =*/ des3_sdctr_encrypt_decrypt,
+    /*.decrypt =*/ des3_sdctr_encrypt_decrypt,
+    NULL, NULL, // WINSCP
+    /*.ssh2_id =*/ "3des-ctr",
+    /*.blksize =*/ 8,
+    /*.real_keybits =*/ 168,
+    /*.padded_keybytes =*/ 24,
+    /*.flags =*/ 0,
+    /*.text_name =*/ "triple-DES SDCTR",
+    NULL, NULL, // WINSCP
 };
 
 static const ssh_cipheralg *const des3_list[] = {
@@ -1062,15 +1074,19 @@ static void des3_cbc3_cbc_decrypt(ssh_cipher *ciph, void *vdata, int len)
 }
 
 const ssh_cipheralg ssh_3des_ssh1 = {
-    .new = des3_cbc3_new,
-    .free = des3_cbc3_free,
-    .setiv = des3_cbc3_setiv,
-    .setkey = des3_cbc3_setkey,
-    .encrypt = des3_cbc3_cbc_encrypt,
-    .decrypt = des3_cbc3_cbc_decrypt,
-    .blksize = 8,
-    .real_keybits = 168,
-    .padded_keybytes = 24,
-    .flags = SSH_CIPHER_IS_CBC,
-    .text_name = "triple-DES inner-CBC",
+    // WINSCP
+    /*.new =*/ des3_cbc3_new,
+    /*.free =*/ des3_cbc3_free,
+    /*.setiv =*/ des3_cbc3_setiv,
+    /*.setkey =*/ des3_cbc3_setkey,
+    /*.encrypt =*/ des3_cbc3_cbc_encrypt,
+    /*.decrypt =*/ des3_cbc3_cbc_decrypt,
+    NULL, NULL, // WINSCP
+    NULL, // WINSCP
+    /*.blksize =*/ 8,
+    /*.real_keybits =*/ 168,
+    /*.padded_keybytes =*/ 24,
+    /*.flags =*/ SSH_CIPHER_IS_CBC,
+    /*.text_name =*/ "triple-DES inner-CBC",
+    NULL, NULL, // WINSCP
 };

+ 17 - 15
source/putty/sshdss.c

@@ -505,19 +505,21 @@ static void dss_sign(ssh_key *key, ptrlen data, unsigned flags, BinarySink *bs)
 }
 
 const ssh_keyalg ssh_dss = {
-    .new_pub = dss_new_pub,
-    .new_priv = dss_new_priv,
-    .new_priv_openssh = dss_new_priv_openssh,
-    .freekey = dss_freekey,
-    .invalid = dss_invalid,
-    .sign = dss_sign,
-    .verify = dss_verify,
-    .public_blob = dss_public_blob,
-    .private_blob = dss_private_blob,
-    .openssh_blob = dss_openssh_blob,
-    .cache_str = dss_cache_str,
-    .components = dss_components,
-    .pubkey_bits = dss_pubkey_bits,
-    .ssh_id = "ssh-dss",
-    .cache_id = "dss",
+    // WINSCP
+    /*.new_pub =*/ dss_new_pub,
+    /*.new_priv =*/ dss_new_priv,
+    /*.new_priv_openssh =*/ dss_new_priv_openssh,
+    /*.freekey =*/ dss_freekey,
+    /*.invalid =*/ dss_invalid,
+    /*.sign =*/ dss_sign,
+    /*.verify =*/ dss_verify,
+    /*.public_blob =*/ dss_public_blob,
+    /*.private_blob =*/ dss_private_blob,
+    /*.openssh_blob =*/ dss_openssh_blob,
+    /*.cache_str =*/ dss_cache_str,
+    /*.components =*/ dss_components,
+    /*.pubkey_bits =*/ dss_pubkey_bits,
+    /*.ssh_id =*/ "ssh-dss",
+    /*.cache_id =*/ "dss",
+    NULL, NULL,
 };

+ 96 - 80
source/putty/sshecc.c

@@ -831,6 +831,7 @@ static key_components *ecdsa_components(ssh_key *key)
     key_components_add_text(kc, "key_type", "ECDSA");
     key_components_add_text(kc, "curve_name", ek->curve->textname);
 
+    { // WINSCP
     mp_int *x, *y;
     ecc_weierstrass_get_affine(ek->publicKey, &x, &y);
     key_components_add_mp(kc, "public_affine_x", x);
@@ -842,6 +843,7 @@ static key_components *ecdsa_components(ssh_key *key)
         key_components_add_mp(kc, "private_exponent", ek->privateKey);
 
     return kc;
+    } // WINSCP
 }
 
 static char *eddsa_cache_str(ssh_key *key)
@@ -866,6 +868,7 @@ static key_components *eddsa_components(ssh_key *key)
     key_components_add_text(kc, "key_type", "EdDSA");
     key_components_add_text(kc, "curve_name", ek->curve->textname);
 
+    { // WINSCP
     mp_int *x, *y;
     ecc_edwards_get_affine(ek->publicKey, &x, &y);
     key_components_add_mp(kc, "public_affine_x", x);
@@ -877,6 +880,7 @@ static key_components *eddsa_components(ssh_key *key)
         key_components_add_mp(kc, "private_exponent", ek->privateKey);
 
     return kc;
+    } // WINSCP
 }
 
 static void ecdsa_public_blob(ssh_key *key, BinarySink *bs)
@@ -1448,22 +1452,24 @@ static const struct ecsign_extra sign_extra_ed25519 = {
     NULL, 0, PTRLEN_DECL_LITERAL(""),
 };
 const ssh_keyalg ssh_ecdsa_ed25519 = {
-    .new_pub = eddsa_new_pub,
-    .new_priv = eddsa_new_priv,
-    .new_priv_openssh = eddsa_new_priv_openssh,
-    .freekey = eddsa_freekey,
-    .invalid = ec_signkey_invalid,
-    .sign = eddsa_sign,
-    .verify = eddsa_verify,
-    .public_blob = eddsa_public_blob,
-    .private_blob = eddsa_private_blob,
-    .openssh_blob = eddsa_openssh_blob,
-    .cache_str = eddsa_cache_str,
-    .components = eddsa_components,
-    .pubkey_bits = ec_shared_pubkey_bits,
-    .ssh_id = "ssh-ed25519",
-    .cache_id = "ssh-ed25519",
-    .extra = &sign_extra_ed25519,
+    // WINSCP
+    /*.new_pub =*/ eddsa_new_pub,
+    /*.new_priv =*/ eddsa_new_priv,
+    /*.new_priv_openssh =*/ eddsa_new_priv_openssh,
+    /*.freekey =*/ eddsa_freekey,
+    /*.invalid =*/ ec_signkey_invalid,
+    /*.sign =*/ eddsa_sign,
+    /*.verify =*/ eddsa_verify,
+    /*.public_blob =*/ eddsa_public_blob,
+    /*.private_blob =*/ eddsa_private_blob,
+    /*.openssh_blob =*/ eddsa_openssh_blob,
+    /*.cache_str =*/ eddsa_cache_str,
+    /*.components =*/ eddsa_components,
+    /*.pubkey_bits =*/ ec_shared_pubkey_bits,
+    /*.ssh_id =*/ "ssh-ed25519",
+    /*.cache_id =*/ "ssh-ed25519",
+    /*.extra =*/ &sign_extra_ed25519,
+    0, // WINSCP
 };
 
 static const struct ecsign_extra sign_extra_ed448 = {
@@ -1471,22 +1477,24 @@ static const struct ecsign_extra sign_extra_ed448 = {
     NULL, 0, PTRLEN_DECL_LITERAL("SigEd448\0\0"),
 };
 const ssh_keyalg ssh_ecdsa_ed448 = {
-    .new_pub = eddsa_new_pub,
-    .new_priv = eddsa_new_priv,
-    .new_priv_openssh = eddsa_new_priv_openssh,
-    .freekey = eddsa_freekey,
-    .invalid = ec_signkey_invalid,
-    .sign = eddsa_sign,
-    .verify = eddsa_verify,
-    .public_blob = eddsa_public_blob,
-    .private_blob = eddsa_private_blob,
-    .openssh_blob = eddsa_openssh_blob,
-    .cache_str = eddsa_cache_str,
-    .components = eddsa_components,
-    .pubkey_bits = ec_shared_pubkey_bits,
-    .ssh_id = "ssh-ed448",
-    .cache_id = "ssh-ed448",
-    .extra = &sign_extra_ed448,
+    // WINSCP
+    /*.new_pub =*/ eddsa_new_pub,
+    /*.new_priv =*/ eddsa_new_priv,
+    /*.new_priv_openssh =*/ eddsa_new_priv_openssh,
+    /*.freekey =*/ eddsa_freekey,
+    /*.invalid =*/ ec_signkey_invalid,
+    /*.sign =*/ eddsa_sign,
+    /*.verify =*/ eddsa_verify,
+    /*.public_blob =*/ eddsa_public_blob,
+    /*.private_blob =*/ eddsa_private_blob,
+    /*.openssh_blob =*/ eddsa_openssh_blob,
+    /*.cache_str =*/ eddsa_cache_str,
+    /*.components =*/ eddsa_components,
+    /*.pubkey_bits =*/ ec_shared_pubkey_bits,
+    /*.ssh_id =*/ "ssh-ed448",
+    /*.cache_id =*/ "ssh-ed448",
+    /*.extra =*/ &sign_extra_ed448,
+    0, // WINSCP
 };
 
 /* OID: 1.2.840.10045.3.1.7 (ansiX9p256r1) */
@@ -1498,22 +1506,24 @@ static const struct ecsign_extra sign_extra_nistp256 = {
     nistp256_oid, lenof(nistp256_oid),
 };
 const ssh_keyalg ssh_ecdsa_nistp256 = {
-    .new_pub = ecdsa_new_pub,
-    .new_priv = ecdsa_new_priv,
-    .new_priv_openssh = ecdsa_new_priv_openssh,
-    .freekey = ecdsa_freekey,
-    .invalid = ec_signkey_invalid,
-    .sign = ecdsa_sign,
-    .verify = ecdsa_verify,
-    .public_blob = ecdsa_public_blob,
-    .private_blob = ecdsa_private_blob,
-    .openssh_blob = ecdsa_openssh_blob,
-    .cache_str = ecdsa_cache_str,
-    .components = ecdsa_components,
-    .pubkey_bits = ec_shared_pubkey_bits,
-    .ssh_id = "ecdsa-sha2-nistp256",
-    .cache_id = "ecdsa-sha2-nistp256",
-    .extra = &sign_extra_nistp256,
+    // WINSCP
+    /*.new_pub =*/ ecdsa_new_pub,
+    /*.new_priv =*/ ecdsa_new_priv,
+    /*.new_priv_openssh =*/ ecdsa_new_priv_openssh,
+    /*.freekey =*/ ecdsa_freekey,
+    /*.invalid =*/ ec_signkey_invalid,
+    /*.sign =*/ ecdsa_sign,
+    /*.verify =*/ ecdsa_verify,
+    /*.public_blob =*/ ecdsa_public_blob,
+    /*.private_blob =*/ ecdsa_private_blob,
+    /*.openssh_blob =*/ ecdsa_openssh_blob,
+    /*.cache_str =*/ ecdsa_cache_str,
+    /*.components =*/ ecdsa_components,
+    /*.pubkey_bits =*/ ec_shared_pubkey_bits,
+    /*.ssh_id =*/ "ecdsa-sha2-nistp256",
+    /*.cache_id =*/ "ecdsa-sha2-nistp256",
+    /*.extra =*/ &sign_extra_nistp256,
+    0, // WINSCP
 };
 
 /* OID: 1.3.132.0.34 (secp384r1) */
@@ -1525,22 +1535,24 @@ static const struct ecsign_extra sign_extra_nistp384 = {
     nistp384_oid, lenof(nistp384_oid),
 };
 const ssh_keyalg ssh_ecdsa_nistp384 = {
-    .new_pub = ecdsa_new_pub,
-    .new_priv = ecdsa_new_priv,
-    .new_priv_openssh = ecdsa_new_priv_openssh,
-    .freekey = ecdsa_freekey,
-    .invalid = ec_signkey_invalid,
-    .sign = ecdsa_sign,
-    .verify = ecdsa_verify,
-    .public_blob = ecdsa_public_blob,
-    .private_blob = ecdsa_private_blob,
-    .openssh_blob = ecdsa_openssh_blob,
-    .cache_str = ecdsa_cache_str,
-    .components = ecdsa_components,
-    .pubkey_bits = ec_shared_pubkey_bits,
-    .ssh_id = "ecdsa-sha2-nistp384",
-    .cache_id = "ecdsa-sha2-nistp384",
-    .extra = &sign_extra_nistp384,
+    // WINSCP
+    /*.new_pub =*/ ecdsa_new_pub,
+    /*.new_priv =*/ ecdsa_new_priv,
+    /*.new_priv_openssh =*/ ecdsa_new_priv_openssh,
+    /*.freekey =*/ ecdsa_freekey,
+    /*.invalid =*/ ec_signkey_invalid,
+    /*.sign =*/ ecdsa_sign,
+    /*.verify =*/ ecdsa_verify,
+    /*.public_blob =*/ ecdsa_public_blob,
+    /*.private_blob =*/ ecdsa_private_blob,
+    /*.openssh_blob =*/ ecdsa_openssh_blob,
+    /*.cache_str =*/ ecdsa_cache_str,
+    /*.components =*/ ecdsa_components,
+    /*.pubkey_bits =*/ ec_shared_pubkey_bits,
+    /*.ssh_id =*/ "ecdsa-sha2-nistp384",
+    /*.cache_id =*/ "ecdsa-sha2-nistp384",
+    /*.extra =*/ &sign_extra_nistp384,
+    0, // WINSCP
 };
 
 /* OID: 1.3.132.0.35 (secp521r1) */
@@ -1552,22 +1564,24 @@ static const struct ecsign_extra sign_extra_nistp521 = {
     nistp521_oid, lenof(nistp521_oid),
 };
 const ssh_keyalg ssh_ecdsa_nistp521 = {
-    .new_pub = ecdsa_new_pub,
-    .new_priv = ecdsa_new_priv,
-    .new_priv_openssh = ecdsa_new_priv_openssh,
-    .freekey = ecdsa_freekey,
-    .invalid = ec_signkey_invalid,
-    .sign = ecdsa_sign,
-    .verify = ecdsa_verify,
-    .public_blob = ecdsa_public_blob,
-    .private_blob = ecdsa_private_blob,
-    .openssh_blob = ecdsa_openssh_blob,
-    .cache_str = ecdsa_cache_str,
-    .components = ecdsa_components,
-    .pubkey_bits = ec_shared_pubkey_bits,
-    .ssh_id = "ecdsa-sha2-nistp521",
-    .cache_id = "ecdsa-sha2-nistp521",
-    .extra = &sign_extra_nistp521,
+    // WINSCP
+    /*.new_pub =*/ ecdsa_new_pub,
+    /*.new_priv =*/ ecdsa_new_priv,
+    /*.new_priv_openssh =*/ ecdsa_new_priv_openssh,
+    /*.freekey =*/ ecdsa_freekey,
+    /*.invalid =*/ ec_signkey_invalid,
+    /*.sign =*/ ecdsa_sign,
+    /*.verify =*/ ecdsa_verify,
+    /*.public_blob =*/ ecdsa_public_blob,
+    /*.private_blob =*/ ecdsa_private_blob,
+    /*.openssh_blob =*/ ecdsa_openssh_blob,
+    /*.cache_str =*/ ecdsa_cache_str,
+    /*.components =*/ ecdsa_components,
+    /*.pubkey_bits =*/ ec_shared_pubkey_bits,
+    /*.ssh_id =*/ "ecdsa-sha2-nistp521",
+    /*.cache_id =*/ "ecdsa-sha2-nistp521",
+    /*.extra =*/ &sign_extra_nistp521,
+    0, // WINSCP
 };
 
 /* ----------------------------------------------------------------------
@@ -1715,6 +1729,7 @@ static mp_int *ssh_ecdhkex_m_getkey(ecdh_key *dh, ptrlen remoteKey)
         return NULL;
     }
 
+    { // WINSCP
     mp_int *x;
     ecc_montgomery_get_affine(p, &x);
 
@@ -1748,6 +1763,7 @@ static mp_int *ssh_ecdhkex_m_getkey(ecdh_key *dh, ptrlen remoteKey)
     } // WINSCP
     } // WINSCP
     } // WINSCP
+    } // WINSCP
 }
 
 mp_int *ssh_ecdhkex_getkey(ecdh_key *dh, ptrlen remoteKey)

+ 72 - 64
source/putty/sshhmac.c

@@ -169,64 +169,68 @@ static const char *hmac_text_name(ssh2_mac *mac)
 
 static const struct hmac_extra ssh_hmac_sha256_extra = { &ssh_sha256, "" };
 const ssh2_macalg ssh_hmac_sha256 = {
-    .new = hmac_new,
-    .free = hmac_free,
-    .setkey = hmac_key,
-    .start = hmac_start,
-    .genresult = hmac_genresult,
-    .text_name = hmac_text_name,
-    .name = "hmac-sha2-256",
-    .etm_name = "[email protected]",
-    .len = 32,
-    .keylen = 32,
-    .extra = &ssh_hmac_sha256_extra,
+    // WINSCP
+    /*.new =*/ hmac_new,
+    /*.free =*/ hmac_free,
+    /*.setkey =*/ hmac_key,
+    /*.start =*/ hmac_start,
+    /*.genresult =*/ hmac_genresult,
+    /*.text_name =*/ hmac_text_name,
+    /*.name =*/ "hmac-sha2-256",
+    /*.etm_name =*/ "[email protected]",
+    /*.len =*/ 32,
+    /*.keylen =*/ 32,
+    /*.extra =*/ &ssh_hmac_sha256_extra,
 };
 
 static const struct hmac_extra ssh_hmac_md5_extra = { &ssh_md5, "" };
 const ssh2_macalg ssh_hmac_md5 = {
-    .new = hmac_new,
-    .free = hmac_free,
-    .setkey = hmac_key,
-    .start = hmac_start,
-    .genresult = hmac_genresult,
-    .text_name = hmac_text_name,
-    .name = "hmac-md5",
-    .etm_name = "[email protected]",
-    .len = 16,
-    .keylen = 16,
-    .extra = &ssh_hmac_md5_extra,
+    // WINSCP
+    /*.new =*/ hmac_new,
+    /*.free =*/ hmac_free,
+    /*.setkey =*/ hmac_key,
+    /*.start =*/ hmac_start,
+    /*.genresult =*/ hmac_genresult,
+    /*.text_name =*/ hmac_text_name,
+    /*.name =*/ "hmac-md5",
+    /*.etm_name =*/ "[email protected]",
+    /*.len =*/ 16,
+    /*.keylen =*/ 16,
+    /*.extra =*/ &ssh_hmac_md5_extra,
 };
 
 static const struct hmac_extra ssh_hmac_sha1_extra = { &ssh_sha1, "" };
 
 const ssh2_macalg ssh_hmac_sha1 = {
-    .new = hmac_new,
-    .free = hmac_free,
-    .setkey = hmac_key,
-    .start = hmac_start,
-    .genresult = hmac_genresult,
-    .text_name = hmac_text_name,
-    .name = "hmac-sha1",
-    .etm_name = "[email protected]",
-    .len = 20,
-    .keylen = 20,
-    .extra = &ssh_hmac_sha1_extra,
+    // WINSCP
+    /*.new =*/ hmac_new,
+    /*.free =*/ hmac_free,
+    /*.setkey =*/ hmac_key,
+    /*.start =*/ hmac_start,
+    /*.genresult =*/ hmac_genresult,
+    /*.text_name =*/ hmac_text_name,
+    /*.name =*/ "hmac-sha1",
+    /*.etm_name =*/ "[email protected]",
+    /*.len =*/ 20,
+    /*.keylen =*/ 20,
+    /*.extra =*/ &ssh_hmac_sha1_extra,
 };
 
 static const struct hmac_extra ssh_hmac_sha1_96_extra = { &ssh_sha1, "-96" };
 
 const ssh2_macalg ssh_hmac_sha1_96 = {
-    .new = hmac_new,
-    .free = hmac_free,
-    .setkey = hmac_key,
-    .start = hmac_start,
-    .genresult = hmac_genresult,
-    .text_name = hmac_text_name,
-    .name = "hmac-sha1-96",
-    .etm_name = "[email protected]",
-    .len = 12,
-    .keylen = 20,
-    .extra = &ssh_hmac_sha1_96_extra,
+    // WINSCP
+    /*.new =*/ hmac_new,
+    /*.free =*/ hmac_free,
+    /*.setkey =*/ hmac_key,
+    /*.start =*/ hmac_start,
+    /*.genresult =*/ hmac_genresult,
+    /*.text_name =*/ hmac_text_name,
+    /*.name =*/ "hmac-sha1-96",
+    /*.etm_name =*/ "[email protected]",
+    /*.len =*/ 12,
+    /*.keylen =*/ 20,
+    /*.extra =*/ &ssh_hmac_sha1_96_extra,
 };
 
 static const struct hmac_extra ssh_hmac_sha1_buggy_extra = {
@@ -234,16 +238,18 @@ static const struct hmac_extra ssh_hmac_sha1_buggy_extra = {
 };
 
 const ssh2_macalg ssh_hmac_sha1_buggy = {
-    .new = hmac_new,
-    .free = hmac_free,
-    .setkey = hmac_key,
-    .start = hmac_start,
-    .genresult = hmac_genresult,
-    .text_name = hmac_text_name,
-    .name = "hmac-sha1",
-    .len = 20,
-    .keylen = 16,
-    .extra = &ssh_hmac_sha1_buggy_extra,
+    // WINSCP
+    /*.new =*/ hmac_new,
+    /*.free =*/ hmac_free,
+    /*.setkey =*/ hmac_key,
+    /*.start =*/ hmac_start,
+    /*.genresult =*/ hmac_genresult,
+    /*.text_name =*/ hmac_text_name,
+    /*.name =*/ "hmac-sha1",
+    NULL, // WINSCP
+    /*.len =*/ 20,
+    /*.keylen =*/ 16,
+    /*.extra =*/ &ssh_hmac_sha1_buggy_extra,
 };
 
 static const struct hmac_extra ssh_hmac_sha1_96_buggy_extra = {
@@ -251,14 +257,16 @@ static const struct hmac_extra ssh_hmac_sha1_96_buggy_extra = {
 };
 
 const ssh2_macalg ssh_hmac_sha1_96_buggy = {
-    .new = hmac_new,
-    .free = hmac_free,
-    .setkey = hmac_key,
-    .start = hmac_start,
-    .genresult = hmac_genresult,
-    .text_name = hmac_text_name,
-    .name = "hmac-sha1-96",
-    .len = 12,
-    .keylen = 16,
-    .extra = &ssh_hmac_sha1_96_buggy_extra,
+    // WINSCP
+    /*.new =*/ hmac_new,
+    /*.free =*/ hmac_free,
+    /*.setkey =*/ hmac_key,
+    /*.start =*/ hmac_start,
+    /*.genresult =*/ hmac_genresult,
+    /*.text_name =*/ hmac_text_name,
+    /*.name =*/ "hmac-sha1-96",
+    NULL, // WINSCP
+    /*.len =*/ 12,
+    /*.keylen =*/ 16,
+    /*.extra =*/ &ssh_hmac_sha1_96_buggy_extra,
 };

+ 9 - 2
source/putty/sshprng.c

@@ -211,12 +211,17 @@ static inline void prng_generate(prng_impl *pi, void *outbuf)
 
     prngdebug("prng_generate\n");
     put_byte(h, 'G');
-    for (unsigned i = 0; i < 128; i += 8)
+    { // WINSCP
+    unsigned i; // WINSCP
+    for (i = 0; i < 128; i += 8)
         put_byte(h, pi->counter[i/BIGNUM_INT_BITS] >> (i%BIGNUM_INT_BITS));
+    { // WINSCP
     BignumCarry c = 1;
-    for (unsigned i = 0; i < lenof(pi->counter); i++)
+    for (i = 0; i < lenof(pi->counter); i++)
         BignumADC(pi->counter[i], c, pi->counter[i], 0, c);
     ssh_hash_final(h, outbuf);
+    } // WINSCP
+    } // WINSCP
 }
 
 void prng_read(prng *pr, void *vout, size_t size)
@@ -232,10 +237,12 @@ void prng_read(prng *pr, void *vout, size_t size)
     uint8_t *out = (uint8_t *)vout;
     while (size > 0) {
         prng_generate(pi, buf);
+        { // WINSCP
         size_t to_use = size > pi->hashalg->hlen ? pi->hashalg->hlen : size;
         memcpy(out, buf, to_use);
         out += to_use;
         size -= to_use;
+        } // WINSCP
     }
 
     smemclr(buf, sizeof(buf));

+ 23 - 6
source/putty/sshpubk.c

@@ -1162,7 +1162,7 @@ static bool rfc4716_loadpub(BinarySource *src, char **algorithm,
     return false;
 }
 
-static bool openssh_loadpub(BinarySource *src, char **algorithm,
+/*WINSCP static*/ bool openssh_loadpub(BinarySource *src, char **algorithm,
                             BinarySink *bs,
                             char **commentptr, const char **errorstr)
 {
@@ -1786,8 +1786,9 @@ static void ssh2_fingerprint_blob_md5(ptrlen blob, strbuf *sb)
 {
     unsigned char digest[16];
 
+    unsigned i; // WINSCP
     hash_simple(&ssh_md5, blob, digest);
-    for (unsigned i = 0; i < 16; i++)
+    for (i = 0; i < 16; i++)
         strbuf_catf(sb, "%02x%s", digest[i], i==15 ? "" : ":");
 }
 
@@ -1798,7 +1799,9 @@ static void ssh2_fingerprint_blob_sha256(ptrlen blob, strbuf *sb)
 
     put_datapl(sb, PTRLEN_LITERAL("SHA256:"));
 
-    for (unsigned i = 0; i < 32; i += 3) {
+    { // WINSCP
+    unsigned i;
+    for (i = 0; i < 32; i += 3) {
         char buf[5];
         unsigned len = 32-i;
         if (len > 3)
@@ -1807,6 +1810,7 @@ static void ssh2_fingerprint_blob_sha256(ptrlen blob, strbuf *sb)
         put_data(sb, buf, 4);
     }
     strbuf_chomp(sb, '=');
+    } // WINSCP
 }
 
 char *ssh2_fingerprint_blob(ptrlen blob, FingerprintType fptype)
@@ -1821,6 +1825,7 @@ char *ssh2_fingerprint_blob(ptrlen blob, FingerprintType fptype)
      */
     BinarySource src[1];
     BinarySource_BARE_INIT_PL(src, blob);
+    { // WINSCP
     ptrlen algname = get_string(src);
     if (!get_err(src)) {
         const ssh_keyalg *alg = find_pubkey_alg_len(algname);
@@ -1831,6 +1836,7 @@ char *ssh2_fingerprint_blob(ptrlen blob, FingerprintType fptype)
             strbuf_catf(sb, "%.*s ", PTRLEN_PRINTF(algname));
         }
     }
+    } // WINSCP
 
     switch (fptype) {
       case SSH_FPTYPE_MD5:
@@ -1847,7 +1853,8 @@ char *ssh2_fingerprint_blob(ptrlen blob, FingerprintType fptype)
 char **ssh2_all_fingerprints_for_blob(ptrlen blob)
 {
     char **fps = snewn(SSH_N_FPTYPES, char *);
-    for (unsigned i = 0; i < SSH_N_FPTYPES; i++)
+    unsigned i; // WINSCP
+    for (i = 0; i < SSH_N_FPTYPES; i++)
         fps[i] = ssh2_fingerprint_blob(blob, i);
     return fps;
 }
@@ -1866,14 +1873,17 @@ char **ssh2_all_fingerprints(ssh_key *data)
 {
     strbuf *blob = strbuf_new();
     ssh_key_public_blob(data, BinarySink_UPCAST(blob));
+    { // WINSCP
     char **ret = ssh2_all_fingerprints_for_blob(ptrlen_from_strbuf(blob));
     strbuf_free(blob);
     return ret;
+    } // WINSCP
 }
 
 void ssh2_free_all_fingerprints(char **fps)
 {
-    for (unsigned i = 0; i < SSH_N_FPTYPES; i++)
+    unsigned i; // WINSCP
+    for (i = 0; i < SSH_N_FPTYPES; i++)
         sfree(fps[i]);
     sfree(fps);
 }
@@ -2001,25 +2011,31 @@ void key_components_add_text(key_components *kc,
                              const char *name, const char *value)
 {
     sgrowarray(kc->components, kc->componentsize, kc->ncomponents);
+    { // WINSCP
     size_t n = kc->ncomponents++;
     kc->components[n].name = dupstr(name);
     kc->components[n].is_mp_int = false;
     kc->components[n].text = dupstr(value);
+    } // WINSCP
 }
 
 void key_components_add_mp(key_components *kc,
                            const char *name, mp_int *value)
 {
     sgrowarray(kc->components, kc->componentsize, kc->ncomponents);
+    { // WINSCP
     size_t n = kc->ncomponents++;
     kc->components[n].name = dupstr(name);
     kc->components[n].is_mp_int = true;
     kc->components[n].mp = mp_copy(value);
+    } // WINSCP
 }
 
 void key_components_free(key_components *kc)
 {
-    for (size_t i = 0; i < kc->ncomponents; i++) {
+    { // WINSCP
+    size_t i;
+    for (i = 0; i < kc->ncomponents; i++) {
         sfree(kc->components[i].name);
         if (kc->components[i].is_mp_int) {
             mp_free(kc->components[i].mp);
@@ -2030,4 +2046,5 @@ void key_components_free(key_components *kc)
     }
     sfree(kc->components);
     sfree(kc);
+    } // WINSCP
 }

+ 33 - 24
source/putty/sshrsa.c

@@ -342,7 +342,8 @@ char *rsa_ssh1_fingerprint(RSAKey *key)
 char **rsa_ssh1_fake_all_fingerprints(RSAKey *key)
 {
     char **ret = snewn(SSH_N_FPTYPES, char *);
-    for (unsigned i = 0; i < SSH_N_FPTYPES; i++)
+    unsigned i; // WINSCP
+    for (i = 0; i < SSH_N_FPTYPES; i++)
         ret[i] = NULL;
     ret[SSH_FPTYPE_MD5] = rsa_ssh1_fingerprint(key);
     return ret;
@@ -871,41 +872,49 @@ static const struct ssh2_rsa_extra
     rsa_sha256_extra = { SSH_AGENT_RSA_SHA2_256 },
     rsa_sha512_extra = { SSH_AGENT_RSA_SHA2_512 };
 
+// WINSCP
 #define COMMON_KEYALG_FIELDS                    \
-    .new_pub = rsa2_new_pub,                    \
-    .new_priv = rsa2_new_priv,                  \
-    .new_priv_openssh = rsa2_new_priv_openssh,  \
-    .freekey = rsa2_freekey,                    \
-    .invalid = rsa2_invalid,                    \
-    .sign = rsa2_sign,                          \
-    .verify = rsa2_verify,                      \
-    .public_blob = rsa2_public_blob,            \
-    .private_blob = rsa2_private_blob,          \
-    .openssh_blob = rsa2_openssh_blob,          \
-    .cache_str = rsa2_cache_str,                \
-    .components = rsa2_components,              \
-    .pubkey_bits = rsa2_pubkey_bits,            \
-    .cache_id = "rsa2"
+    /*.new_pub =*/ rsa2_new_pub,                    \
+    /*.new_priv =*/ rsa2_new_priv,                  \
+    /*.new_priv_openssh =*/ rsa2_new_priv_openssh,  \
+    /*.freekey =*/ rsa2_freekey,                    \
+    /*.invalid =*/ rsa2_invalid,                    \
+    /*.sign =*/ rsa2_sign,                          \
+    /*.verify =*/ rsa2_verify,                      \
+    /*.public_blob =*/ rsa2_public_blob,            \
+    /*.private_blob =*/ rsa2_private_blob,          \
+    /*.openssh_blob =*/ rsa2_openssh_blob,          \
+    /*.cache_str =*/ rsa2_cache_str,                \
+    /*.components =*/ rsa2_components,              \
+    /*.pubkey_bits =*/ rsa2_pubkey_bits
+#define COMMON_KEYALG_FIELDS2 \
+    /*.cache_id =*/ "rsa2"
 
 const ssh_keyalg ssh_rsa = {
+    // WINSCP
     COMMON_KEYALG_FIELDS,
-    .ssh_id = "ssh-rsa",
-    .supported_flags = SSH_AGENT_RSA_SHA2_256 | SSH_AGENT_RSA_SHA2_512,
-    .extra = &rsa_extra,
+    /*.ssh_id =*/ "ssh-rsa",
+    COMMON_KEYALG_FIELDS2,
+    /*.extra =*/ &rsa_extra,
+    /*.supported_flags =*/ SSH_AGENT_RSA_SHA2_256 | SSH_AGENT_RSA_SHA2_512,
 };
 
 const ssh_keyalg ssh_rsa_sha256 = {
+    // WINSCP
     COMMON_KEYALG_FIELDS,
-    .ssh_id = "rsa-sha2-256",
-    .supported_flags = 0,
-    .extra = &rsa_sha256_extra,
+    /*.ssh_id =*/ "rsa-sha2-256",
+    COMMON_KEYALG_FIELDS2,
+    /*.extra =*/ &rsa_sha256_extra,
+    /*.supported_flags =*/ 0,
 };
 
 const ssh_keyalg ssh_rsa_sha512 = {
+    // WINSCP
     COMMON_KEYALG_FIELDS,
-    .ssh_id = "rsa-sha2-512",
-    .supported_flags = 0,
-    .extra = &rsa_sha512_extra,
+    /*.ssh_id =*/ "rsa-sha2-512",
+    COMMON_KEYALG_FIELDS2,
+    /*.extra =*/ &rsa_sha512_extra,
+    /*.supported_flags =*/ 0,
 };
 
 RSAKey *ssh_rsakex_newkey(ptrlen data)

+ 10 - 5
source/putty/sshshare.c

@@ -1904,9 +1904,11 @@ void share_activate(ssh_sharing_state *sharestate,
 }
 
 static const PlugVtable ssh_sharing_conn_plugvt = {
-    .closing = share_closing,
-    .receive = share_receive,
-    .sent = share_sent,
+    NULL, // WINSCP
+    /*.closing =*/ share_closing,
+    /*.receive =*/ share_receive,
+    /*.sent =*/ share_sent,
+    NULL, // WINSCP
 };
 
 static int share_listen_accepting(Plug *plug,
@@ -2046,8 +2048,11 @@ bool ssh_share_test_for_upstream(const char *host, int port, Conf *conf)
 }
 
 static const PlugVtable ssh_sharing_listen_plugvt = {
-    .closing = share_listen_closing,
-    .accepting = share_listen_accepting,
+    NULL, // WINSCP
+    // WINSCP
+    /*.closing =*/ share_listen_closing,
+    NULL, NULL, // WINSCP
+    /*.accepting =*/ share_listen_accepting,
 };
 
 void ssh_connshare_provide_connlayer(ssh_sharing_state *sharestate,

+ 7 - 6
source/putty/sshverstring.c

@@ -46,12 +46,13 @@ static void ssh_verstring_queue_disconnect(BinaryPacketProtocol *bpp,
                                           const char *msg, int category);
 
 static const BinaryPacketProtocolVtable ssh_verstring_vtable = {
-    .free = ssh_verstring_free,
-    .handle_input = ssh_verstring_handle_input,
-    .handle_output = ssh_verstring_handle_output,
-    .new_pktout = ssh_verstring_new_pktout,
-    .queue_disconnect = ssh_verstring_queue_disconnect,
-    .packet_size_limit = 0xFFFFFFFF, /* no special limit for this bpp */
+    // WINSCP
+    /*.free =*/ ssh_verstring_free,
+    /*.handle_input =*/ ssh_verstring_handle_input,
+    /*.handle_output =*/ ssh_verstring_handle_output,
+    /*.new_pktout =*/ ssh_verstring_new_pktout,
+    /*.queue_disconnect =*/ ssh_verstring_queue_disconnect,
+    /*.packet_size_limit =*/ 0xFFFFFFFF, /* no special limit for this bpp */
 };
 
 static void ssh_detect_bugs(struct ssh_verstring_state *s);

+ 10 - 9
source/putty/sshzlib.c

@@ -1241,13 +1241,14 @@ bool zlib_decompress_block(ssh_decompressor *dc,
 }
 
 const ssh_compression_alg ssh_zlib = {
-    .name = "zlib",
-    .delayed_name = "[email protected]", /* delayed version */
-    .compress_new = zlib_compress_init,
-    .compress_free = zlib_compress_cleanup,
-    .compress = zlib_compress_block,
-    .decompress_new = zlib_decompress_init,
-    .decompress_free = zlib_decompress_cleanup,
-    .decompress = zlib_decompress_block,
-    .text_name = "zlib (RFC1950)",
+    // WINSCP
+    /*.name =*/ "zlib",
+    /*.delayed_name =*/ "[email protected]", /* delayed version */
+    /*.compress_new =*/ zlib_compress_init,
+    /*.compress_free =*/ zlib_compress_cleanup,
+    /*.compress =*/ zlib_compress_block,
+    /*.decompress_new =*/ zlib_decompress_init,
+    /*.decompress_free =*/ zlib_decompress_cleanup,
+    /*.decompress =*/ zlib_decompress_block,
+    /*.text_name =*/ "zlib (RFC1950)",
 };

+ 2 - 1
source/putty/utils.c

@@ -1069,7 +1069,8 @@ size_t encode_utf8(void *output, unsigned long ch)
 
 void write_c_string_literal(FILE *fp, ptrlen str)
 {
-    for (const char *p = str.ptr; p < (const char *)str.ptr + str.len; p++) {
+    const char *p; // WINSCP
+    for (p = str.ptr; p < (const char *)str.ptr + str.len; p++) {
         char c = *p;
 
         if (c == '\n')

+ 6 - 0
source/putty/windows/winhandl.c

@@ -579,6 +579,12 @@ static void handle_destroy(struct handle *h)
     CloseHandle(h->u.g.ev_to_main);
     del234(handles_by_evtomain, h);
     sfree(h);
+    // WINSCP (memory leak)
+    if (count234(handles_by_evtomain) == 0)
+    {
+        freetree234(handles_by_evtomain);
+        handles_by_evtomain = NULL;
+    }
 }
 
 void handle_free(struct handle *h)

+ 9 - 8
source/putty/windows/winhsock.c

@@ -325,14 +325,15 @@ static SocketPeerInfo *sk_handle_peer_info(Socket *s)
 }
 
 static const SocketVtable HandleSocket_sockvt = {
-    .plug = sk_handle_plug,
-    .close = sk_handle_close,
-    .write = sk_handle_write,
-    .write_oob = sk_handle_write_oob,
-    .write_eof = sk_handle_write_eof,
-    .set_frozen = sk_handle_set_frozen,
-    .socket_error = sk_handle_socket_error,
-    .peer_info = sk_handle_peer_info,
+    // WINSCP
+    /*.plug =*/ sk_handle_plug,
+    /*.close =*/ sk_handle_close,
+    /*.write =*/ sk_handle_write,
+    /*.write_oob =*/ sk_handle_write_oob,
+    /*.write_eof =*/ sk_handle_write_eof,
+    /*.set_frozen =*/ sk_handle_set_frozen,
+    /*.socket_error =*/ sk_handle_socket_error,
+    /*.peer_info =*/ sk_handle_peer_info,
 };
 
 Socket *make_handle_socket(HANDLE send_H, HANDLE recv_H, HANDLE stderr_H,

+ 11 - 8
source/putty/windows/winnet.c

@@ -840,14 +840,15 @@ static const char *sk_net_socket_error(Socket *s);
 static SocketPeerInfo *sk_net_peer_info(Socket *s);
 
 static const SocketVtable NetSocket_sockvt = {
-    .plug = sk_net_plug,
-    .close = sk_net_close,
-    .write = sk_net_write,
-    .write_oob = sk_net_write_oob,
-    .write_eof = sk_net_write_eof,
-    .set_frozen = sk_net_set_frozen,
-    .socket_error = sk_net_socket_error,
-    .peer_info = sk_net_peer_info,
+    // WINSCP
+    /*.plug =*/ sk_net_plug,
+    /*.close =*/ sk_net_close,
+    /*.write =*/ sk_net_write,
+    /*.write_oob =*/ sk_net_write_oob,
+    /*.write_eof =*/ sk_net_write_eof,
+    /*.set_frozen =*/ sk_net_set_frozen,
+    /*.socket_error =*/ sk_net_socket_error,
+    /*.peer_info =*/ sk_net_peer_info,
 };
 
 static Socket *sk_net_accept(accept_ctx_t ctx, Plug *plug)
@@ -1130,9 +1131,11 @@ static DWORD try_connect(NetSocket *sock,
          * and we should set the socket as writable.
          */
         sock->writable = true;
+        { // WINSCP
         SockAddr thisaddr = sk_extractaddr_tmp(sock->addr, &sock->step);
         plug_log(sock->plug, PLUGLOG_CONNECT_SUCCESS,
                  &thisaddr, sock->port, NULL, 0);
+        } // WINSCP
     }
 
 #ifdef MPEXT

+ 8 - 1
source/putty/windows/winpgntc.c

@@ -183,9 +183,11 @@ static int named_pipe_agent_accumulate_response(
         if (length_field > AGENT_MAX_MSGLEN)
             return -1; /* badly formatted message */
 
+        { // WINSCP
         int overall_length = length_field + 4;
         if (sb->len >= overall_length)
             return overall_length;
+        } // WINSCP
     }
 
     return 0; /* not done yet */
@@ -202,6 +204,7 @@ static size_t named_pipe_agent_gotdata(
         return 0;
     }
 
+    { // WINSCP
     int status = named_pipe_agent_accumulate_response(pq->response, data, len);
     if (status == -1) {
         pq->callback(pq->callback_ctx, NULL, 0);
@@ -213,6 +216,7 @@ static size_t named_pipe_agent_gotdata(
         agent_cancel_query(pq);
     }
     return 0;
+    } // WINSCP
 }
 
 static agent_pending_query *named_pipe_agent_query(
@@ -231,7 +235,9 @@ static agent_pending_query *named_pipe_agent_query(
 
     strbuf_finalise_agent_query(query);
 
-    for (DWORD done = 0; done < query->len ;) {
+    { // WINSCP
+    DWORD done; // WINSCP
+    for (done = 0; done < query->len ;) {
         DWORD nwritten;
         bool ret = WriteFile(pipehandle, query->s + done, query->len - done,
                              &nwritten, NULL);
@@ -285,6 +291,7 @@ static agent_pending_query *named_pipe_agent_query(
     if (sb)
         strbuf_free(sb);
     return pq;
+    } // WINSCP
 }
 
 void agent_cancel_query(agent_pending_query *pq)

+ 29 - 26
source/putty/x11fwd.c

@@ -766,10 +766,12 @@ int x11_get_screen_number(char *display)
 }
 
 static const PlugVtable X11Connection_plugvt = {
-    .log = x11_log,
-    .closing = x11_closing,
-    .receive = x11_receive,
-    .sent = x11_sent,
+    // WINSCP
+    /*.log =*/ x11_log,
+    /*.closing =*/ x11_closing,
+    /*.receive =*/ x11_receive,
+    /*.sent =*/ x11_sent,
+    NULL,
 };
 
 static void x11_chan_free(Channel *chan);
@@ -780,28 +782,29 @@ static void x11_set_input_wanted(Channel *chan, bool wanted);
 static char *x11_log_close_msg(Channel *chan);
 
 static const ChannelVtable X11Connection_channelvt = {
-    .free = x11_chan_free,
-    .open_confirmation = chan_remotely_opened_confirmation,
-    .open_failed = chan_remotely_opened_failure,
-    .send = x11_send,
-    .send_eof = x11_send_eof,
-    .set_input_wanted = x11_set_input_wanted,
-    .log_close_msg = x11_log_close_msg,
-    .want_close = chan_default_want_close,
-    .rcvd_exit_status = chan_no_exit_status,
-    .rcvd_exit_signal = chan_no_exit_signal,
-    .rcvd_exit_signal_numeric = chan_no_exit_signal_numeric,
-    .run_shell = chan_no_run_shell,
-    .run_command = chan_no_run_command,
-    .run_subsystem = chan_no_run_subsystem,
-    .enable_x11_forwarding = chan_no_enable_x11_forwarding,
-    .enable_agent_forwarding = chan_no_enable_agent_forwarding,
-    .allocate_pty = chan_no_allocate_pty,
-    .set_env = chan_no_set_env,
-    .send_break = chan_no_send_break,
-    .send_signal = chan_no_send_signal,
-    .change_window_size = chan_no_change_window_size,
-    .request_response = chan_no_request_response,
+    // WINSCP
+    /*.free =*/ x11_chan_free,
+    /*.open_confirmation =*/ chan_remotely_opened_confirmation,
+    /*.open_failed =*/ chan_remotely_opened_failure,
+    /*.send =*/ x11_send,
+    /*.send_eof =*/ x11_send_eof,
+    /*.set_input_wanted =*/ x11_set_input_wanted,
+    /*.log_close_msg =*/ x11_log_close_msg,
+    /*.want_close =*/ chan_default_want_close,
+    /*.rcvd_exit_status =*/ chan_no_exit_status,
+    /*.rcvd_exit_signal =*/ chan_no_exit_signal,
+    /*.rcvd_exit_signal_numeric =*/ chan_no_exit_signal_numeric,
+    /*.run_shell =*/ chan_no_run_shell,
+    /*.run_command =*/ chan_no_run_command,
+    /*.run_subsystem =*/ chan_no_run_subsystem,
+    /*.enable_x11_forwarding =*/ chan_no_enable_x11_forwarding,
+    /*.enable_agent_forwarding =*/ chan_no_enable_agent_forwarding,
+    /*.allocate_pty =*/ chan_no_allocate_pty,
+    /*.set_env =*/ chan_no_set_env,
+    /*.send_break =*/ chan_no_send_break,
+    /*.send_signal =*/ chan_no_send_signal,
+    /*.change_window_size =*/ chan_no_change_window_size,
+    /*.request_response =*/ chan_no_request_response,
 };
 
 /*