[Ttssh2-commit] [7416] エラーがうまく表示されていなかった

scmno****@osdn***** scmno****@osdn*****
2019年 1月 28日 (月) 23:15:35 JST


Revision: 7416
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/7416
Author:   zmatsuo
Date:     2019-01-28 23:15:35 +0900 (Mon, 28 Jan 2019)
Log Message:
-----------
エラーがうまく表示されていなかった
コンパイル時警告を修正

Modified Paths:
--------------
    branches/cmake/ttssh2/ttxssh/auth.c

-------------- next part --------------
Modified: branches/cmake/ttssh2/ttxssh/auth.c
===================================================================
--- branches/cmake/ttssh2/ttxssh/auth.c	2019-01-28 14:15:21 UTC (rev 7415)
+++ branches/cmake/ttssh2/ttxssh/auth.c	2019-01-28 14:15:35 UTC (rev 7416)
@@ -487,6 +487,8 @@
 
 static BOOL end_auth_dlg(PTInstVar pvar, HWND dlg)
 {
+	char uimsg[MAX_UIMSG];
+
 	int method = SSH_AUTH_PASSWORD;
 	char *password =
 		alloc_control_text(GetDlgItem(dlg, IDC_SSHPASSWORD));
@@ -514,11 +516,10 @@
 		keyfile[0] = 0;
 		GetDlgItemText(dlg, file_ctl_ID, keyfile, sizeof(keyfile));
 		if (keyfile[0] == 0) {
-			char buf[1024];
-			UTIL_get_lang_msgU8("MSG_KEYSPECIFY_ERROR", buf, _countof(buf),
+			UTIL_get_lang_msgU8("MSG_KEYSPECIFY_ERROR", uimsg, _countof(uimsg),
 								"You must specify a file containing the RSA/DSA/ECDSA/ED25519 private key.",
 							   pvar->ts->UILanguageFile);
-			notify_nonfatal_error(pvar, buf);
+			notify_nonfatal_error(pvar, uimsg);
 			SetFocus(GetDlgItem(dlg, file_ctl_ID));
 			destroy_malloced_string(&password);
 			return FALSE;
@@ -586,7 +587,7 @@
 				}
 				default:
 				{
-					char uimsg[1024];
+					char buf[1024];
 
 					// \x83t\x83@\x83C\x83\x8B\x82\xAA\x8AJ\x82\xAF\x82\xBD\x8Fꍇ\x82̓t\x83@\x83C\x83\x8B\x8C`\x8E\xAE\x82\xAA\x95s\x96\xBE\x82ł\xE0\x93ǂݍ\x9E\x82\xF1\x82ł݂\xE9
 					if (fp != NULL) {
@@ -602,7 +603,8 @@
 					UTIL_get_lang_msgU8("MSG_READKEY_ERROR", uimsg, _countof(uimsg),
 										"read error SSH2 private key file\r\n%s",
 										pvar->ts->UILanguageFile);
-					notify_nonfatal_error(pvar, uimsg);
+					_snprintf_s(buf, sizeof(buf), _TRUNCATE, uimsg, errmsg);
+					notify_nonfatal_error(pvar, buf);
 					// \x82\xB1\x82\xB1\x82ɗ\x88\x82\xBD\x82Ƃ\xA2\x82\xA4\x82\xB1\x82Ƃ\xCD SSH2 \x94閧\x8C\xAE\x83t\x83@\x83C\x83\x8B\x82\xAA\x8AJ\x82\xAF\x82Ȃ\xA2\x82̂\xC5
 					// \x8C\xAE\x83t\x83@\x83C\x83\x8B\x82̑I\x91\xF0\x83{\x83^\x83\x93\x82Ƀt\x83H\x81[\x83J\x83X\x82\xF0\x88ڂ\xB7
 					SetFocus(GetDlgItem(dlg, IDC_CHOOSERSAFILE));
@@ -613,9 +615,10 @@
 
 			if (key_pair == NULL) { // read error
 				char buf[1024];
-				UTIL_get_lang_msgU8("MSG_READKEY_ERROR", buf, _countof(buf),
+				UTIL_get_lang_msgU8("MSG_READKEY_ERROR", uimsg, _countof(uimsg),
 									"read error SSH2 private key file\r\n%s",
 									pvar->ts->UILanguageFile);
+				_snprintf_s(buf, sizeof(buf), _TRUNCATE, uimsg, errmsg);
 				notify_nonfatal_error(pvar, buf);
 				// \x83p\x83X\x83t\x83\x8C\x81[\x83Y\x82\xAA\x8C\xAE\x82ƈ\xEA\x92v\x82\xB5\x82Ȃ\xA9\x82\xC1\x82\xBD\x8Fꍇ\x82\xCDIDC_SSHPASSWORD\x82Ƀt\x83H\x81[\x83J\x83X\x82\xF0\x88ڂ\xB7 (2006.10.29 yasuhide)
 				if (invalid_passphrase) {
@@ -649,10 +652,9 @@
 			pvar->pageant_keylistlen = putty_get_ssh2_keylist(&pvar->pageant_key);
 		}
 		if (pvar->pageant_keylistlen == 0) {
-			char buf[1024];
-			UTIL_get_lang_msgU8("MSG_PAGEANT_NOTFOUND", buf, _countof(buf),
+			UTIL_get_lang_msgU8("MSG_PAGEANT_NOTFOUND", uimsg, _countof(uimsg),
 								"Can't find Pageant.", pvar->ts->UILanguageFile);
-			notify_nonfatal_error(pvar, buf);
+			notify_nonfatal_error(pvar, uimsg);
 
 			return FALSE;
 		}
@@ -661,11 +663,9 @@
 		// \x8C\xAE\x82̐\x94
 		pvar->pageant_keycount = get_uint32_MSBfirst(pvar->pageant_curkey);
 		if (pvar->pageant_keycount == 0) {
-			char buf[1024];
-			UTIL_get_lang_msgU8("MSG_PAGEANT_NOKEY", buf, _countof(buf),
-								"Pageant has no valid key.",
-								pvar->ts->UILanguageFile);
-			notify_nonfatal_error(pvar, buf);
+			UTIL_get_lang_msgU8("MSG_PAGEANT_NOKEY", uimsg, _countof(uimsg),
+								"Pageant has no valid key.", pvar->ts->UILanguageFile);
+			notify_nonfatal_error(pvar, uimsg);
 
 			return FALSE;
 		}
@@ -700,7 +700,6 @@
 	}
 	if (method == SSH_AUTH_RHOSTS || method == SSH_AUTH_RHOSTS_RSA) {
 		if (pvar->session_settings.DefaultAuthMethod != SSH_AUTH_RHOSTS) {
-			char uimsg[MAX_UIMSG];
 			UTIL_get_lang_msgU8("MSG_RHOSTS_NOTDEFAULT_ERROR", uimsg, _countof(uimsg),
 								"Rhosts authentication will probably fail because it was not "
 								"the default authentication method.\n"


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