浏览代码

Updating code to PuTTY 8001dd4c

Source commit: 72932a0b3f9b0a72abe62cbce5eee2f692127350
Martin Prikryl 6 年之前
父节点
当前提交
22dd9478aa

+ 21 - 2
source/core/PuttyIntf.cpp

@@ -88,8 +88,7 @@ TSecureShell * GetSecureShell(Plug plug, bool & pfwd)
   void * frontend;
   if (pfwd)
   {
-    Ssh ssh = get_pfwd_ssh(plug);
-    frontend = ssh_get_frontend(ssh);
+    frontend = get_pfwd_frontend(plug);
   }
   else
   {
@@ -1018,4 +1017,24 @@ UnicodeString GetCipher2Name(const ssh2_cipher * Cipher)
   return UnicodeString(UTF8String((*Cipher)->text_name));
 }
 //---------------------------------------------------------------------------
+UnicodeString GetCompressorName(const ssh_compressor * Compressor)
+{
+  UnicodeString Result;
+  if (Compressor != NULL)
+  {
+    Result = UnicodeString(UTF8String(Compressor->vt->name));
+  }
+  return Result;
+}
+//---------------------------------------------------------------------------
+UnicodeString GetDecompressorName(const ssh_decompressor * Decompressor)
+{
+  UnicodeString Result;
+  if (Decompressor != NULL)
+  {
+    Result = UnicodeString(UTF8String(Decompressor->vt->name));
+  }
+  return Result;
+}
+//---------------------------------------------------------------------------
 //---------------------------------------------------------------------------

+ 2 - 0
source/core/PuttyIntf.h

@@ -29,5 +29,7 @@ extern "C"
 //---------------------------------------------------------------------------
 UnicodeString GetCipher1Name(const ssh1_cipher * Cipher);
 UnicodeString GetCipher2Name(const ssh2_cipher * Cipher);
+UnicodeString GetCompressorName(const ssh_compressor * Compressor);
+UnicodeString GetDecompressorName(const ssh_decompressor * Decompressor);
 //---------------------------------------------------------------------------
 #endif

+ 5 - 19
source/core/SecureShell.cpp

@@ -98,20 +98,20 @@ inline void __fastcall TSecureShell::UpdateSessionInfo()
       FORMAT(L"%s-%d", (FSessionInfo.ProtocolBaseName, get_ssh_version(FBackendHandle)));
     FSessionInfo.SecurityProtocolName = FSessionInfo.ProtocolName;
 
-    FSessionInfo.CSCompression =
-      FuncToCompression(FSshVersion, get_cscomp(FBackendHandle));
-    FSessionInfo.SCCompression =
-      FuncToCompression(FSshVersion, get_sccomp(FBackendHandle));
-
     if (FSshVersion == 1)
     {
       FSessionInfo.CSCipher = GetCipher1Name(get_cipher(FBackendHandle));
       FSessionInfo.SCCipher = FSessionInfo.CSCipher;
+      // Retrieval of compression is not implemented for SSH-1
+      FSessionInfo.CSCompression = UnicodeString();
+      FSessionInfo.SCCompression = UnicodeString();
     }
     else
     {
       FSessionInfo.CSCipher = GetCipher2Name(get_cscipher(FBackendHandle));
       FSessionInfo.SCCipher = GetCipher2Name(get_sccipher(FBackendHandle));
+      FSessionInfo.CSCompression = GetCompressorName(get_cscomp(FBackendHandle));
+      FSessionInfo.SCCompression = GetDecompressorName(get_sccomp(FBackendHandle));
     }
 
     FSessionInfoValid = true;
@@ -2082,20 +2082,6 @@ unsigned long __fastcall TSecureShell::MaxPacketSize()
   }
 }
 //---------------------------------------------------------------------------
-UnicodeString __fastcall TSecureShell::FuncToCompression(
-  int SshVersion, const void * Compress) const
-{
-  enum TCompressionType { ctNone, ctZLib };
-  if (SshVersion == 1)
-  {
-    return get_ssh1_compressing(FBackendHandle) ? L"ZLib" : L"";
-  }
-  else
-  {
-    return (ssh_compress *)Compress == &ssh_zlib ? L"ZLib" : L"";
-  }
-}
-//---------------------------------------------------------------------------
 UnicodeString __fastcall TSecureShell::FormatKeyStr(UnicodeString KeyStr)
 {
   int Index = 1;

+ 0 - 1
source/core/SecureShell.h

@@ -73,7 +73,6 @@ private:
   int FSendBuf;
   std::auto_ptr<callback_set> FCallbackSet;
 
-  UnicodeString __fastcall FuncToCompression(int SshVersion, const void * Compress) const;
   void __fastcall Init();
   void __fastcall SetActive(bool value);
   void inline __fastcall CheckConnection(int Message = -1);

+ 5 - 3
source/putty/portfwd.c

@@ -849,6 +849,7 @@ void portfwdmgr_config(PortFwdManager *mgr, Conf *conf)
                                   address_family == '6' ? ADDRTYPE_IPV6 :
                                   ADDRTYPE_UNSPEC);
 
+            { // WINSCP
             PortFwdRecord *existing = add234(mgr->forwardings, pfr);
             if (existing != pfr) {
                 if (existing->status == DESTROY) {
@@ -868,6 +869,7 @@ void portfwdmgr_config(PortFwdManager *mgr, Conf *conf)
             } else {
                 pfr->status = CREATE;
             }
+            } // WINSCP
         } else {
             sfree(saddr);
             sfree(host);
@@ -1076,18 +1078,18 @@ int is_pfwd(Plug plug)
     ((*plug)->closing == pfl_closing);
 }
 
-Ssh get_pfwd_ssh(Plug plug)
+Frontend * get_pfwd_frontend(Plug plug)
 {
   Ssh ssh = NULL;
   if ((*plug)->closing == pfl_closing)
   {
     struct PortListener *pl = FROMFIELD(plug, struct PortListener, plugvt);
-    ssh = pl->ssh;
+    ssh = pl->cl->frontend;
   }
   else if ((*plug)->closing == pfd_closing)
   {
     struct PortForwarding *pf = FROMFIELD(plug, struct PortForwarding, plugvt);
-    ssh = pf->ssh;
+    ssh = pf->cl->frontend;
   }
   return ssh;
 }

+ 3 - 8
source/putty/puttyexp.h

@@ -14,12 +14,11 @@ int is_ssh(Plug plug);
 void call_ssh_timer(Backend * be);
 int get_ssh_version(Backend * be);
 void * get_ssh_frontend(Plug plug);
-int get_ssh1_compressing(Backend * be);
 const ssh1_cipher * get_cipher(Backend * be);
 const ssh2_cipher * get_cscipher(Backend * be);
 const ssh2_cipher * get_sccipher(Backend * be);
-const struct ssh_compress * get_cscomp(Backend * be);
-const struct ssh_compress * get_sccomp(Backend * be);
+const struct ssh_compressor * get_cscomp(Backend * be);
+const struct ssh_decompressor * get_sccomp(Backend * be);
 int get_ssh_state_closed(Backend * be);
 int get_ssh_state_session(Backend * be);
 const unsigned int * ssh2_remmaxpkt(Backend * be);
@@ -38,7 +37,7 @@ void get_macs(int * count, const struct ssh2_macalg *** amacs);
 // from portfwd.c
 
 int is_pfwd(Plug plug);
-Ssh get_pfwd_ssh(Plug plug);
+Frontend * get_pfwd_frontend(Plug plug);
 
 // for winstore.c
 
@@ -62,10 +61,6 @@ void putty_unmungestr(const char *in, char *out, int outlen);
 
 void select_result(WPARAM wParam, LPARAM lParam);
 
-// from sshzlib.c
-
-extern const struct ssh_compress ssh_zlib;
-
 // from sshaes.c
 
 void call_aes_setup(void * ctx, unsigned char * key, int keylen);

+ 8 - 8
source/putty/ssh.c

@@ -3742,10 +3742,12 @@ static void ssh_rportfwd_succfail(Ssh ssh, PktIn *pktin, void *ctx)
 	logeventf(ssh, "Remote port forwarding from %s refused",
                   rpf->log_description);
 
+        { // WINSCP
         struct ssh_rportfwd *realpf = del234(ssh->rportfwds, rpf);
         assert(realpf == rpf);
         portfwdmgr_close(ssh->portfwdmgr, rpf->pfr);
         free_rportfwd(rpf);
+        } // WINSCP
     }
 }
 
@@ -3809,6 +3811,7 @@ static struct ssh_rportfwd *(ssh_rportfwd_alloc)(
             ssh->rportfwds = newtree234(ssh_rportcmp_ssh2);
     }
 
+    { // WINSCP
     struct ssh_rportfwd *rpf = snew(struct ssh_rportfwd);
 
     rpf->shost = dupstr(shost);
@@ -3853,6 +3856,7 @@ static struct ssh_rportfwd *(ssh_rportfwd_alloc)(
     }
 
     return rpf;
+    } // WINSCP
 }
 
 static void (ssh_rportfwd_remove)(
@@ -3880,9 +3884,11 @@ static void (ssh_rportfwd_remove)(
         ssh2_pkt_send(ssh, pktout);
     }
 
+    { // WINSCP
     struct ssh_rportfwd *realpf = del234(ssh->rportfwds, rpf);
     assert(realpf == rpf);
     free_rportfwd(rpf);
+    } // WINSCP
 }
 
 static void ssh_sharing_global_request_response(Ssh ssh, PktIn *pktin,
@@ -11190,12 +11196,6 @@ void * get_ssh_frontend(Plug plug)
   return FROMFIELD(plug, struct ssh_tag, plugvt)->frontend;
 }
 
-int get_ssh1_compressing(Backend * be)
-{
-  Ssh ssh = FROMFIELD(be, struct ssh_tag, backend);
-  return ssh1_bpp_get_compressing(ssh->bpp);
-}
-
 const ssh1_cipher * get_cipher(Backend * be)
 {
   Ssh ssh = FROMFIELD(be, struct ssh_tag, backend);
@@ -11214,13 +11214,13 @@ const ssh2_cipher * get_sccipher(Backend * be)
   return ssh2_bpp_get_sccipher(ssh->bpp);
 }
 
-const struct ssh_compress * get_cscomp(Backend * be)
+const struct ssh_compressor * get_cscomp(Backend * be)
 {
   Ssh ssh = FROMFIELD(be, struct ssh_tag, backend);
   return ssh2_bpp_get_cscomp(ssh->bpp);
 }
 
-const struct ssh_compress * get_sccomp(Backend * be)
+const struct ssh_decompressor * get_sccomp(Backend * be)
 {
   Ssh ssh = FROMFIELD(be, struct ssh_tag, backend);
   return ssh2_bpp_get_sccomp(ssh->bpp);

+ 0 - 5
source/putty/ssh1bpp.c

@@ -281,11 +281,6 @@ static void ssh1_bpp_format_packet(BinaryPacketProtocol *bpp, PktOut *pkt)
 }
 
 #ifdef MPEXT
-int ssh1_bpp_get_compressing(BinaryPacketProtocol *bpp)
-{
-    return FROMFIELD(bpp, struct ssh1_bpp_state, bpp)->compctx != NULL;
-}
-
 const ssh1_cipher * ssh1_bpp_get_cipher(BinaryPacketProtocol *bpp)
 {
     return FROMFIELD(bpp, struct ssh1_bpp_state, bpp)->cipher;

+ 4 - 4
source/putty/ssh2bpp.c

@@ -687,14 +687,14 @@ const ssh2_cipher * ssh2_bpp_get_sccipher(BinaryPacketProtocol *bpp)
     return FROMFIELD(bpp, struct ssh2_bpp_state, bpp)->in.cipher;
 }
 
-const struct ssh_compress * ssh2_bpp_get_cscomp(BinaryPacketProtocol *bpp)
+const struct ssh_compressor * ssh2_bpp_get_cscomp(BinaryPacketProtocol *bpp)
 {
-    return FROMFIELD(bpp, struct ssh2_bpp_state, bpp)->out.comp;
+    return FROMFIELD(bpp, struct ssh2_bpp_state, bpp)->out_comp;
 }
 
-const struct ssh_compress * ssh2_bpp_get_sccomp(BinaryPacketProtocol *bpp)
+const struct ssh_decompressor * ssh2_bpp_get_sccomp(BinaryPacketProtocol *bpp)
 {
-    return FROMFIELD(bpp, struct ssh2_bpp_state, bpp)->in.comp;
+    return FROMFIELD(bpp, struct ssh2_bpp_state, bpp)->in_decomp;
 }
 
 #endif

+ 2 - 3
source/putty/sshbpp.h

@@ -52,11 +52,10 @@ BinaryPacketProtocol *ssh2_bare_bpp_new(void);
 
 #ifdef MPEXT
 const ssh1_cipher * ssh1_bpp_get_cipher(BinaryPacketProtocol *bpp);
-int ssh1_bpp_get_compressing(BinaryPacketProtocol *bpp);
 const ssh2_cipher * ssh2_bpp_get_cscipher(BinaryPacketProtocol *bpp);
 const ssh2_cipher * ssh2_bpp_get_sccipher(BinaryPacketProtocol *bpp);
-const struct ssh_compress * ssh2_bpp_get_cscomp(BinaryPacketProtocol *bpp);
-const struct ssh_compress * ssh2_bpp_get_sccomp(BinaryPacketProtocol *bpp);
+const struct ssh_compressor * ssh2_bpp_get_cscomp(BinaryPacketProtocol *bpp);
+const struct ssh_decompressor * ssh2_bpp_get_sccomp(BinaryPacketProtocol *bpp);
 #endif
 
 #endif /* PUTTY_SSHBPP_H */

+ 1 - 1
source/putty/sshmd5.c

@@ -319,7 +319,7 @@ void hmacmd5_do_hmac(struct hmacmd5_context *ctx,
 {
     ssh2_mac_start(&ctx->mac);
     put_data(&ctx->mac, blk, len);
-    return ssh2_mac_genresult(&ctx->mac, hmac);
+    /*WINSCP return*/ ssh2_mac_genresult(&ctx->mac, hmac);
 }
 
 const struct ssh2_macalg ssh_hmac_md5 = {

+ 4 - 0
source/putty/windows/winstore.c

@@ -124,9 +124,11 @@ settings_w *open_settings_w(const char *sessionname, char **errmsg)
     }
     sfree(p);
 
+    { // WINSCP
     settings_w *toret = snew(settings_w);
     toret->sesskey = sesskey;
     return toret;
+    } // WINSCP
 }
 
 void write_setting_s(settings_w *handle, const char *key, const char *value)
@@ -175,9 +177,11 @@ settings_r *open_settings_r(const char *sessionname)
 
     sfree(p);
 
+    { // WINSCP
     settings_r *toret = snew(settings_r);
     toret->sesskey = sesskey;
     return toret;
+    } // WINSCP
 }
 
 char *read_setting_s(settings_r *handle, const char *key)