[Ttssh2-commit] [5422] SSH2 でポートフォワードを繰り返すと新たにポートフォワード接続できなくなる問題を修正

svnno****@sourc***** svnno****@sourc*****
2013年 11月 21日 (木) 23:24:33 JST


Revision: 5422
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/5422
Author:   maya
Date:     2013-11-21 23:24:32 +0900 (Thu, 21 Nov 2013)
Log Message:
-----------
SSH2 でポートフォワードを繰り返すと新たにポートフォワード接続できなくなる問題を修正
  SSH_MSG_CHANNEL_CLOSE を受信したときに SSH_MSG_CHANNEL_CLOSE を送り返していなかった
  http://sourceforge.jp/ticket/browse.php?group_id=1412&tid=32468

Modified Paths:
--------------
    trunk/doc/en/html/about/history.html
    trunk/doc/ja/html/about/history.html
    trunk/ttssh2/ttxssh/ssh.c
    trunk/ttssh2/ttxssh/ssh.h

-------------- next part --------------
Modified: trunk/doc/en/html/about/history.html
===================================================================
--- trunk/doc/en/html/about/history.html	2013-11-20 12:46:23 UTC (rev 5421)
+++ trunk/doc/en/html/about/history.html	2013-11-21 14:24:32 UTC (rev 5422)
@@ -61,6 +61,7 @@
 
   <li>Misc
     <ul>
+      <li>upgraded TTSSH to <a href="#ttssh_2.67">2.67</a></li>
       <li>upgraded TTXRecurringCommand Plugin to <a href="#recurringcommand_1.03">1.03</a></li>
       <li>added support for Microsoft Windows 8.1.</li>
       <li>upgraded Oniguruma to 5.9.5.</li>
@@ -2335,6 +2336,15 @@
 
 <h2><a name="ttssh">TTSSH</a></h2>
 
+<h3><a name="ttssh_2.67">2013.xx.xx (Ver 2.67)</a></h3>
+<ul class="history">
+  <li>Bug fixes
+    <ul>
+      <!--li>SSH2 \x82Ń|\x81[\x83g\x83t\x83H\x83\x8F\x81[\x83h\x82\xF0\x8CJ\x82\xE8\x95Ԃ\xB7\x82ƐV\x82\xBD\x82Ƀ|\x81[\x83g\x83t\x83H\x83\x8F\x81[\x83h\x90ڑ\xB1\x82ł\xAB\x82Ȃ\xAD\x82Ȃ\xE9\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B</li-->
+    </ul>
+  </li>
+</ul>
+
 <h3><a name="ttssh_2.66">2013.09.01 (Ver 2.66)</a></h3>
 <ul class="history">
   <li>Changes

Modified: trunk/doc/ja/html/about/history.html
===================================================================
--- trunk/doc/ja/html/about/history.html	2013-11-20 12:46:23 UTC (rev 5421)
+++ trunk/doc/ja/html/about/history.html	2013-11-21 14:24:32 UTC (rev 5422)
@@ -61,6 +61,7 @@
 
   <li>\x82\xBB\x82̑\xBC
     <ul>
+      <li><a href="#ttssh_2.67">TTSSH(2.67)</a>\x82֍\xB7\x82\xB5\x91ւ\xA6\x82\xBD\x81B</li>
       <li><a href="#recurringcommand_1.03">TTXRecurringCommand Plugin(1.03)</a>\x82֍\xB7\x82\xB5\x91ւ\xA6\x82\xBD\x81B</li>
       <li>\x91Ή\x9E\x82\xB7\x82铮\x8D\xEC\x8A‹\xAB\x82\xC9Windows 8.1\x82\xF0\x92lj\xC1\x82\xB5\x82\xBD\x81B</li>
       <li>Oniguruma 5.9.5\x82֍\xB7\x82\xB5\x91ւ\xA6\x82\xBD</li>
@@ -2340,6 +2341,15 @@
 
 <h2><a name="ttssh">TTSSH</a></h2>
 
+<h3><a name="ttssh_2.67">2013.xx.xx (Ver 2.67)</a></h3>
+<ul class="history">
+  <li>\x83o\x83O\x8FC\x90\xB3
+    <ul>
+      <li>SSH2 \x82Ń|\x81[\x83g\x83t\x83H\x83\x8F\x81[\x83h\x82\xF0\x8CJ\x82\xE8\x95Ԃ\xB7\x82ƐV\x82\xBD\x82Ƀ|\x81[\x83g\x83t\x83H\x83\x8F\x81[\x83h\x90ڑ\xB1\x82ł\xAB\x82Ȃ\xAD\x82Ȃ\xE9\x96\xE2\x91\xE8\x82\xF0\x8FC\x90\xB3\x82\xB5\x82\xBD\x81B</li>
+    </ul>
+  </li>
+</ul>
+
 <h3><a name="ttssh_2.66">2013.09.01 (Ver 2.66)</a></h3>
 <ul class="history">
   <li>\x95ύX

Modified: trunk/ttssh2/ttxssh/ssh.c
===================================================================
--- trunk/ttssh2/ttxssh/ssh.c	2013-11-20 12:46:23 UTC (rev 5421)
+++ trunk/ttssh2/ttxssh/ssh.c	2013-11-21 14:24:32 UTC (rev 5422)
@@ -164,6 +164,7 @@
 		c->agent_msg = buffer_init();
 		c->agent_request_len = 0;
 	}
+	c->state = 0;
 
 	return (c);
 }
@@ -2742,6 +2743,8 @@
 		finish_send_packet(pvar);
 		buffer_free(msg);
 
+		c->state |= SSH_CHANNEL_STATE_CLOSE_SENT;
+
 		notify_verbose_message(pvar, "SSH2_MSG_CHANNEL_CLOSE was sent at SSH_notify_disconnecting().", LOG_LEVEL_VERBOSE);
 	}
 
@@ -7540,6 +7543,11 @@
 		int len;
 		char log[128];
 
+		// \x82\xB1\x82\xCCchannel\x82ɂ‚\xA2\x82\xC4close\x82𑗐M\x8Dς݂Ȃ瑗\x82\xE7\x82Ȃ\xA2
+		if (c->state & SSH_CHANNEL_STATE_CLOSE_SENT) {
+			return;
+		}
+
 		// SSH2 server\x82\xC9channel close\x82\xF0\x93`\x82\xA6\x82\xE9
 		msg = buffer_init();
 		if (msg == NULL) {
@@ -7554,6 +7562,8 @@
 		finish_send_packet(pvar);
 		buffer_free(msg);
 
+		c->state |= SSH_CHANNEL_STATE_CLOSE_SENT;
+
 		_snprintf_s(log, sizeof(log), _TRUNCATE, "SSH2_MSG_CHANNEL_CLOSE was sent at ssh2_channel_send_close(). local:%d remote:%d", c->self_id, c->remote_id);
 		notify_verbose_message(pvar, log, LOG_LEVEL_VERBOSE);
 	}
@@ -8491,6 +8501,10 @@
 		notify_closed_connection(pvar);
 
 	} else if (c->type == TYPE_PORTFWD) {
+		// CHANNEL_CLOSE \x82𑗂\xE8\x95Ԃ\xB3\x82Ȃ\xA2\x82ƃ\x8A\x83\x82\x81[\x83g\x82\xCCchannel\x82\xAA\x8AJ\x95\xFA\x82\xB3\x82\xEA\x82Ȃ\xA2
+		// c.f. RFC 4253 5.3. Closing a Channel
+		ssh2_channel_send_close(pvar, c);
+
 		// \x93]\x91\x97\x83`\x83\x83\x83l\x83\x8B\x93\xE0\x82ɂ\xA0\x82\xE9\x83\\x83P\x83b\x83g\x82̉\xF0\x95\xFA\x98R\x82\xEA\x82\xF0\x8FC\x90\xB3 (2007.7.26 maya)
 		FWD_free_channel(pvar, c->local_num);
 
@@ -8503,7 +8517,7 @@
 	} else if (c->type == TYPE_AGENT) {
 		ssh2_channel_delete(c);
 
-	} else { // TYPE_PORTFWD
+	} else {
 		ssh2_channel_delete(c);
 
 	}

Modified: trunk/ttssh2/ttxssh/ssh.h
===================================================================
--- trunk/ttssh2/ttxssh/ssh.h	2013-11-20 12:46:23 UTC (rev 5421)
+++ trunk/ttssh2/ttxssh/ssh.h	2013-11-21 14:24:32 UTC (rev 5422)
@@ -697,6 +697,8 @@
 	buffer_t *agent_msg;
 	int agent_request_len;
 	sftp_t sftp;
+#define SSH_CHANNEL_STATE_CLOSE_SENT 0x00000001
+	unsigned int state;
 } Channel_t;
 
 unsigned char FAR *begin_send_packet(PTInstVar pvar, int type, int len);



Ttssh2-commit メーリングリストの案内