[Ttssh2-commit] [4306] エラー時のメッセージの関数名を修正

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2011年 2月 15日 (火) 09:21:10 JST


Revision: 4306
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=4306
Author:   maya
Date:     2011-02-15 09:21:10 +0900 (Tue, 15 Feb 2011)

Log Message:
-----------
エラー時のメッセージの関数名を修正
デバッグ用のメモリダンプ箇所を追加

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


-------------- next part --------------
Modified: trunk/ttssh2/ttxssh/ssh.c
===================================================================
--- trunk/ttssh2/ttxssh/ssh.c	2011-02-14 14:30:19 UTC (rev 4305)
+++ trunk/ttssh2/ttxssh/ssh.c	2011-02-15 00:21:10 UTC (rev 4306)
@@ -4951,13 +4951,14 @@
 	len = pvar->ssh_state.payloadlen;
 
 	// for debug
-	//write_buffer_file(data, len);
 	push_memdump("KEXDH_REPLY", "key exchange: receiving", data, len);
 
 	bloblen = get_uint32_MSBfirst(data);
 	data += 4;
 	server_host_key_blob = data; // for hash
 
+	push_memdump("KEXDH_REPLY", "server_host_key_blob", server_host_key_blob, bloblen);
+
 	// key_from_blob()#key.c ‚̏ˆ—‚ªˆÈ‰º‚©‚çŽn‚Ü‚éB
 	// known_hostsŒŸØ—p‚Ì server_host_key ‚Í rsa or dsa ‚Æ‚È‚éB
 	keynamelen = get_uint32_MSBfirst(data);
@@ -4970,6 +4971,8 @@
 	key[keynamelen] = 0;
 	data += keynamelen;
 
+	push_memdump("KEXDH_REPLY", "keyname", key, keynamelen);
+
 	// RSA key
 	if (strcmp(key, "ssh-rsa") == 0) {
 		rsa = RSA_new();
@@ -5086,6 +5089,16 @@
 	                   share_key,
 	                   &hashlen);
 
+	{
+		push_memdump("KEXDH_REPLY kex_dh_kex_hash", "my_kex", buffer_ptr(pvar->my_kex), buffer_len(pvar->my_kex));
+		push_memdump("KEXDH_REPLY kex_dh_kex_hash", "peer_kex", buffer_ptr(pvar->peer_kex), buffer_len(pvar->peer_kex));
+
+		push_bignum_memdump("KEXDH_REPLY kex_dh_kex_hash", "dh_server_pub", dh_server_pub);
+		push_bignum_memdump("KEXDH_REPLY kex_dh_kex_hash", "share_key", share_key);
+
+		push_memdump("KEXDH_REPLY kex_dh_kex_hash", "hash", hash, hashlen);
+	}
+
 	//debug_print(30, hash, hashlen);
 	//debug_print(31, pvar->client_version_string, strlen(pvar->client_version_string));
 	//debug_print(32, pvar->server_version_string, strlen(pvar->server_version_string));
@@ -5117,7 +5130,7 @@
 		}
 		else {
 			_snprintf_s(emsg_tmp, sizeof(emsg_tmp), _TRUNCATE,
-			            "key verify error(%d) @ handle_SSH2_dh_kex_reply()", ret);
+			            "key verify error(%d) @ handle_SSH2_dh_kex_reply()\r\n%s", ret, SENDTOME);
 		}
 		emsg = emsg_tmp;
 		save_memdump(LOGDUMP);
@@ -5227,10 +5240,8 @@
 	// ƒpƒPƒbƒgƒTƒCƒY - (ƒpƒfƒBƒ“ƒOƒTƒCƒY+1)G^‚̃pƒPƒbƒgƒTƒCƒY
 	len = pvar->ssh_state.payloadlen;
 
-	push_memdump("DH_GEX_REPLY", "full dump", data, len);
-
 	// for debug
-	//write_buffer_file(data, len);
+	push_memdump("DH_GEX_REPLY", "key exchange: receiving", data, len);
 
 	bloblen = get_uint32_MSBfirst(data);
 	data += 4;
@@ -5242,7 +5253,7 @@
 	// known_hostsŒŸØ—p‚Ì server_host_key ‚Í rsa or dsa ‚Æ‚È‚éB
 	keynamelen = get_uint32_MSBfirst(data);
 	if (keynamelen >= 128) {
-		emsg = "keyname length too big @ handle_SSH2_dh_kex_reply()";
+		emsg = "keyname length too big @ handle_SSH2_dh_gex_reply()";
 		goto error;
 	}
 	data +=4 ;
@@ -5256,13 +5267,13 @@
 	if (strcmp(key, "ssh-rsa") == 0) {
 		rsa = RSA_new();
 		if (rsa == NULL) {
-			emsg = "Out of memory1 @ handle_SSH2_dh_kex_reply()";
+			emsg = "Out of memory1 @ handle_SSH2_dh_gex_reply()";
 			goto error;
 		}
 		rsa->n = BN_new();
 		rsa->e = BN_new();
 		if (rsa->n == NULL || rsa->e == NULL) {
-			emsg = "Out of memory2 @ handle_SSH2_dh_kex_reply()";
+			emsg = "Out of memory2 @ handle_SSH2_dh_gex_reply()";
 			goto error;
 		}
 
@@ -5275,7 +5286,7 @@
 	} else if (strcmp(key, "ssh-dss") == 0) { // DSA key
 		dsa = DSA_new();
 		if (dsa == NULL) {
-			emsg = "Out of memory3 @ handle_SSH2_dh_kex_reply()";
+			emsg = "Out of memory3 @ handle_SSH2_dh_gex_reply()";
 			goto error;
 		}
 		dsa->p = BN_new();
@@ -5286,7 +5297,7 @@
 		    dsa->q == NULL ||
 		    dsa->g == NULL ||
 		    dsa->pub_key == NULL) {
-			emsg = "Out of memory4 @ handle_SSH2_dh_kex_reply()";
+			emsg = "Out of memory4 @ handle_SSH2_dh_gex_reply()";
 			goto error;
 		}
 
@@ -5301,7 +5312,7 @@
 	} else {
 		// unknown key
 		_snprintf_s(emsg_tmp, sizeof(emsg_tmp), _TRUNCATE,
-		            "Unknown key type(%s) @ handle_SSH2_dh_kex_reply()", key);
+		            "Unknown key type(%s) @ handle_SSH2_dh_gex_reply()", key);
 		emsg = emsg_tmp;
 		goto error;
 
@@ -5322,7 +5333,7 @@
 
 	dh_server_pub = BN_new();
 	if (dh_server_pub == NULL) {
-		emsg = "Out of memory5 @ handle_SSH2_dh_kex_reply()";
+		emsg = "Out of memory5 @ handle_SSH2_dh_gex_reply()";
 		goto error;
 	}
 
@@ -5337,20 +5348,20 @@
 
 	// check DH public value
 	if (!dh_pub_is_valid(pvar->kexdh, dh_server_pub)) {
-		emsg = "DH public value invalid @ handle_SSH2_dh_kex_reply()";
+		emsg = "DH public value invalid @ handle_SSH2_dh_gex_reply()";
 		goto error;
 	}
 	// ‹¤’ÊŒ®‚̐¶¬
 	dh_len = DH_size(pvar->kexdh);
 	dh_buf = malloc(dh_len);
 	if (dh_buf == NULL) {
-		emsg = "Out of memory6 @ handle_SSH2_dh_kex_reply()";
+		emsg = "Out of memory6 @ handle_SSH2_dh_gex_reply()";
 		goto error;
 	}
 	share_len = DH_compute_key(dh_buf, dh_server_pub, pvar->kexdh);
 	share_key = BN_new();
 	if (share_key == NULL) {
-		emsg = "Out of memory7 @ handle_SSH2_dh_kex_reply()";
+		emsg = "Out of memory7 @ handle_SSH2_dh_gex_reply()";
 		goto error;
 	}
 	// 'share_key'‚ªƒT[ƒo‚ƃNƒ‰ƒCƒAƒ“ƒg‚Å‹¤—L‚·‚錮iG^A~B mod Pj‚Æ‚È‚éB
@@ -5411,7 +5422,7 @@
 			if (!pvar->settings.EnableRsaShortKeyServer) {
 				_snprintf_s(emsg_tmp, sizeof(emsg_tmp), _TRUNCATE,
 				            "key verify error(remote rsa key length is too short %d-bit) "
-				            "@ SSH2_DH_GEX", BN_num_bits(rsa->n));
+				            "@ handle_SSH2_dh_gex_reply", BN_num_bits(rsa->n));
 			}
 			else {
 				goto cont;
@@ -5419,7 +5430,7 @@
 		}
 		else {
 			_snprintf_s(emsg_tmp, sizeof(emsg_tmp), _TRUNCATE,
-			            "key verify error(%d) @ SSH2_DH_GEX\r\n%s", ret, SENDTOME);
+			            "key verify error(%d) @ handle_SSH2_dh_gex_reply()\r\n%s", ret, SENDTOME);
 		}
 		emsg = emsg_tmp;
 		save_memdump(LOGDUMP);



Ttssh2-commit メーリングリストの案内
Back to archive index