[Ttssh2-commit] [5829] チケット #35010 Unexpected SSH2 message (80) エラー

svnno****@sourc***** svnno****@sourc*****
2015年 3月 27日 (金) 00:04:46 JST


Revision: 5829
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/5829
Author:   yutakapon
Date:     2015-03-27 00:04:45 +0900 (Fri, 27 Mar 2015)
Log Message:
-----------
チケット #35010 Unexpected SSH2 message(80)エラー

OpenSSH 6.8で接続エラーが出ないようにした。
"SSH2_MSG_GLOBAL_REQUEST"の正式対応はTBD。

Ticket Links:
------------
    http://sourceforge.jp/projects/ttssh2/tracker/detail/35010

Modified Paths:
--------------
    trunk/ttssh2/ttxssh/ssh.c

-------------- next part --------------
Modified: trunk/ttssh2/ttxssh/ssh.c
===================================================================
--- trunk/ttssh2/ttxssh/ssh.c	2015-03-24 14:24:02 UTC (rev 5828)
+++ trunk/ttssh2/ttxssh/ssh.c	2015-03-26 15:04:45 UTC (rev 5829)
@@ -100,6 +100,7 @@
 static BOOL handle_SSH2_userauth_banner(PTInstVar pvar);
 static BOOL handle_SSH2_open_confirm(PTInstVar pvar);
 static BOOL handle_SSH2_open_failure(PTInstVar pvar);
+static BOOL handle_SSH2_client_global_request(PTInstVar pvar);
 static BOOL handle_SSH2_request_success(PTInstVar pvar);
 static BOOL handle_SSH2_request_failure(PTInstVar pvar);
 static BOOL handle_SSH2_channel_success(PTInstVar pvar);
@@ -1669,7 +1670,7 @@
 		enque_handler(pvar, SSH2_MSG_CHANNEL_WINDOW_ADJUST, handle_SSH2_window_adjust);
 		enque_handler(pvar, SSH2_MSG_CHANNEL_SUCCESS, handle_SSH2_channel_success);
 		enque_handler(pvar, SSH2_MSG_CHANNEL_FAILURE, handle_SSH2_channel_failure);
-//		enque_handler(pvar, SSH2_MSG_GLOBAL_REQUEST, handle_unimplemented);
+		enque_handler(pvar, SSH2_MSG_GLOBAL_REQUEST, handle_SSH2_client_global_request);
 		enque_handler(pvar, SSH2_MSG_REQUEST_FAILURE, handle_SSH2_request_failure);
 		enque_handler(pvar, SSH2_MSG_REQUEST_SUCCESS, handle_SSH2_request_success);
 
@@ -6094,7 +6095,7 @@
 	pvar->rekeying = 0;
 
 	SSH2_dispatch_init(6);
-	SSH2_dispatch_add_range_message(SSH2_MSG_REQUEST_SUCCESS, SSH2_MSG_CHANNEL_FAILURE);
+	SSH2_dispatch_add_range_message(SSH2_MSG_GLOBAL_REQUEST, SSH2_MSG_CHANNEL_FAILURE);
 	SSH2_dispatch_add_message(SSH2_MSG_IGNORE); // XXX
 	// OpenSSH 3.9\x82ł̓f\x81[\x83^\x92ʐM\x92\x86\x82\xCCDH\x8C\xAE\x8C\xF0\x8A\xB7\x97v\x8B\x81\x82\xAA\x81A\x83T\x81[\x83o\x82\xA9\x82瑗\x82\xE7\x82\xEA\x82Ă\xAD\x82邱\x82Ƃ\xAA\x82\xA0\x82\xE9\x81B
 	SSH2_dispatch_add_message(SSH2_MSG_KEXINIT);
@@ -7419,6 +7420,49 @@
 }
 
 
+// SSH2_MSG_GLOBAL_REQUEST for OpenSSH 6.8
+static BOOL handle_SSH2_client_global_request(PTInstVar pvar)
+{
+	int len;
+	char *data;
+	char *rtype;
+	int want_reply;
+	int success = 0;
+	buffer_t *msg;
+	unsigned char *outmsg;
+	int type;
+
+	notify_verbose_message(pvar, "SSH2_MSG_GLOBAL_REQUEST was received.", LOG_LEVEL_VERBOSE);
+
+	// 6byte\x81i\x83T\x83C\x83Y\x81{\x83p\x83f\x83B\x83\x93\x83O\x81{\x83^\x83C\x83v\x81j\x82\xF0\x8E\xE6\x82菜\x82\xA2\x82\xBD\x88ȍ~\x82̃y\x83C\x83\x8D\x81[\x83h
+	data = pvar->ssh_state.payload;
+	// \x83p\x83P\x83b\x83g\x83T\x83C\x83Y - (\x83p\x83f\x83B\x83\x93\x83O\x83T\x83C\x83Y+1)\x81G\x90^\x82̃p\x83P\x83b\x83g\x83T\x83C\x83Y
+	len = pvar->ssh_state.payloadlen;
+
+	rtype = buffer_get_string(&data, NULL);
+	want_reply = data[0];
+
+	// OpenSSH 6.8\x82ł́A\x83T\x81[\x83o\x82̃z\x83X\x83g\x8C\xAE\x82\xAA\x8DX\x90V\x82\xB3\x82\xEA\x82\xE9\x82ƁA\x89\xBA\x8BL\x82̒ʒm\x82\xAA\x97\x88\x82\xE9\x81B
+	if (strcmp(rtype, "hostk****@opens*****") == 0) {
+		// TODO: \x8C\xBB\x8F\xF3\x81ATera Term\x82Ƃ\xB5\x82Ă͖\xA2\x83T\x83|\x81[\x83g\x82Ȃ̂ŁA\x8E\xB8\x94s\x82ŕԂ\xB7\x81B
+		success = 0;
+	}
+	free(rtype);
+
+	msg = buffer_init();
+	if (msg) {
+		len = buffer_len(msg);
+		type = success ? SSH2_MSG_REQUEST_SUCCESS : SSH2_MSG_REQUEST_FAILURE;
+		outmsg = begin_send_packet(pvar, type, len);
+		memcpy(outmsg, buffer_ptr(msg), len);
+		finish_send_packet(pvar);
+		buffer_free(msg);
+	}
+
+	return TRUE;
+}
+
+
 // SSH2 port-forwarding (remote -> local)\x82ɑ΂\xB7\x82郊\x83v\x83\x89\x83C\x81i\x90\xAC\x8C\xF7\x81j
 static BOOL handle_SSH2_request_success(PTInstVar pvar)
 {	



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