Ver código fonte

Bug 1845: Failure when fallback SSH channel fails to open (reimplementation with a help of PuTTY fix)

https://git.tartarus.org/?p=simon/putty.git;a=commit;h=e4b6a7efd2cab27a681c9a832f6c650abf57c7be

https://winscp.net/tracker/1845

Source commit: 6a07974041c29f45e317657b2b62053d5a6009c5
Martin Prikryl 5 anos atrás
pai
commit
045d5261c0

+ 2 - 3
source/core/PuttyIntf.cpp

@@ -166,10 +166,9 @@ static size_t output(Seat * seat, bool is_stderr, const void * data, size_t len)
   return 0;
 }
 //---------------------------------------------------------------------------
-static bool eof(Seat * seat)
+static bool eof(Seat *)
 {
-  TSecureShell * SecureShell = static_cast<ScpSeat *>(seat)->SecureShell;
-  return SecureShell->EofReceived();
+  return false;
 }
 //---------------------------------------------------------------------------
 static int get_userpass_input(Seat * seat, prompts_t * p, bufchain * DebugUsedArg(input))

+ 0 - 12
source/core/SecureShell.cpp

@@ -74,7 +74,6 @@ __fastcall TSecureShell::TSecureShell(TSessionUI* UI,
   FSimple = false;
   FCollectPrivateKeyUsage = false;
   FWaitingForData = 0;
-  FSentEof = false;
   FCallbackSet.reset(new callback_set());
   memset(FCallbackSet.get(), 0, sizeof(callback_set));
 }
@@ -102,7 +101,6 @@ void __fastcall TSecureShell::ResetConnection()
   FStoredPasswordTried = false;
   FStoredPasswordTriedForKI = false;
   FStoredPassphraseTried = false;
-  FSentEof = false;
   delete FLogPolicy;
   FLogPolicy = NULL;
   delete FSeat;
@@ -1004,15 +1002,6 @@ void __fastcall TSecureShell::UnregisterReceiveHandler(TNotifyEvent Handler)
   FOnReceive = NULL;
 }
 //---------------------------------------------------------------------------
-bool __fastcall TSecureShell::EofReceived()
-{
-  if (!FSentEof)
-  {
-    FatalError(MainInstructions(LoadStr(NOT_CONNECTED)));
-  }
-  return false;
-}
-//---------------------------------------------------------------------------
 void __fastcall TSecureShell::FromBackend(const unsigned char * Data, size_t Length)
 {
   // Note that we do not apply ConvertFromPutty to Data yet (as opposite to CWrite).
@@ -1702,7 +1691,6 @@ void __fastcall TSecureShell::Close()
   {
     // this is particularly necessary when using local proxy command
     // (e.g. plink), otherwise it hangs in sk_localproxy_close
-    FSentEof = true;
     SendSpecial(SS_EOF);
     // Try waiting for the EOF exchange to complete (among other to avoid packet queue memory leaks)
     int Timeout = 500;

+ 0 - 2
source/core/SecureShell.h

@@ -76,7 +76,6 @@ private:
   ScpLogPolicy * FLogPolicy;
   ScpSeat * FSeat;
   LogContext * FLogCtx;
-  bool FSentEof;
 
   void __fastcall Init();
   void __fastcall SetActive(bool value);
@@ -156,7 +155,6 @@ public:
     UnicodeString AName, bool NameRequired,
     UnicodeString Instructions, bool InstructionsRequired,
     TStrings * Prompts, TStrings * Results);
-  bool __fastcall EofReceived();
   void __fastcall FromBackend(const unsigned char * Data, size_t Length);
   void __fastcall CWrite(const char * Data, size_t Length);
   void __fastcall AddStdError(const char * Data, size_t Length);

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

@@ -319,7 +319,8 @@ SshChannel *ssh2_serverside_agent_open(ConnectionLayer *cl, Channel *chan)
 static void ssh2_channel_response(
     struct ssh2_channel *c, PktIn *pkt, void *ctx)
 {
-    chan_request_response(c->chan, pkt->type == SSH2_MSG_CHANNEL_SUCCESS);
+    chan_request_response(c->chan,
+                          pkt && pkt->type == SSH2_MSG_CHANNEL_SUCCESS);
 }
 
 void ssh2channel_start_shell(SshChannel *sc, bool want_reply)