svnno****@sourc*****
svnno****@sourc*****
2009年 6月 2日 (火) 22:03:25 JST
Revision: 3433 http://svn.sourceforge.jp/view?root=ttssh2&view=rev&rev=3433 Author: maya Date: 2009-06-02 22:03:24 +0900 (Tue, 02 Jun 2009) Log Message: ----------- TTSSH ã®ã³ãã³ãã©ã¤ã³ã§ @ ãã¹ãã¼ã¹ã«ã@@ ã @ ã«ããä»æ§ãå»æ¢ããã Modified Paths: -------------- trunk/ttpmenu/ttpmenu.cpp trunk/ttssh2/ttxssh/ttxssh.c -------------- next part -------------- Modified: trunk/ttpmenu/ttpmenu.cpp =================================================================== --- trunk/ttpmenu/ttpmenu.cpp 2009-06-01 19:34:31 UTC (rev 3432) +++ trunk/ttpmenu/ttpmenu.cpp 2009-06-02 13:03:24 UTC (rev 3433) @@ -1060,6 +1060,46 @@ } +static void _dquote_string(char *str, char *dst, int dst_len) +{ + int i, len, n; + + len = strlen(str); + n = 0; + for (i = 0 ; i < len ; i++) { + if (str[i] == '"') + n++; + } + if (dst_len < (len + 2*n + 2 + 1)) + return; + + *dst++ = '"'; + for (i = 0 ; i < len ; i++) { + if (str[i] == '"') { + *dst++ = '"'; + *dst++ = '"'; + + } else { + *dst++ = str[i]; + + } + } + *dst++ = '"'; + *dst = '\0'; +} + +static void dquote_string(char *str, char *dst, int dst_len) +{ + // " ÅnÜé©AXy[XªÜÜêéêÉÍNI[g·é + if (str[0] == '"' || strchr(str, '" ') != NULL) { + _dquote_string(str, dst, dst_len); + return; + } + // »ÌÜÜRs[µÄßé + strncpy_s(dst, dst_len, str, _TRUNCATE); +} + +#ifdef USE_ATCMDLINE // óð @ Éu«·¦éB@©gÍ@@É·éB(2005.1.28 yutaka) static void replace_blank_to_mark(char *str, char *dst, int dst_len) { @@ -1090,6 +1130,7 @@ *dst = '\0'; } +#endif /* ========================================================================== @@ -1186,8 +1227,13 @@ char passwd[MAX_PATH], keyfile[MAX_PATH]; strcpy(tmp, szArgment); +#ifdef USE_ATCMDLINE replace_blank_to_mark(jobInfo.szPassword, passwd, sizeof(passwd)); replace_blank_to_mark(jobInfo.PrivateKeyFile, keyfile, sizeof(keyfile)); +#else + dquote_string(jobInfo.szPassword, passwd, sizeof(passwd)); + dquote_string(jobInfo.PrivateKeyFile, keyfile, sizeof(keyfile)); +#endif if (jobInfo.bChallenge) { // keyboard-interactive _snprintf(szArgment, sizeof(szArgment), "%s:22 /ssh /auth=challenge /user=%s /passwd=%s %s", Modified: trunk/ttssh2/ttxssh/ttxssh.c =================================================================== --- trunk/ttssh2/ttxssh/ttxssh.c 2009-06-01 19:34:31 UTC (rev 3432) +++ trunk/ttssh2/ttxssh/ttxssh.c 2009-06-02 13:03:24 UTC (rev 3433) @@ -1432,7 +1432,7 @@ FWDUI_load_settings(pvar); } - +#ifdef USE_ATCMDLINE // @ðuNÉu··éB (2005.1.26 yutaka) static void replace_to_blank(char *src, char *dst, int dst_len) { @@ -1456,6 +1456,7 @@ } *dst = '\0'; } +#endif // Percent-encode³ê½¶ñsrcðfR[hµÄdstÉRs[·éB // dstlenÍdstÌTCYB±êæèʪ·¢êA»ÌªÍØèÌÄçêéB @@ -1612,15 +1613,28 @@ } } else if (MATCH_STR(option + 1, "user=") == 0) { +#ifdef USE_ATCMDLINE replace_to_blank(option + 6, pvar->ssh2_username, sizeof(pvar->ssh2_username)); //_snprintf(pvar->ssh2_username, sizeof(pvar->ssh2_username), "%s", option + 6); +#else + _snprintf_s(pvar->ssh2_username, sizeof(pvar->ssh2_username), _TRUNCATE, "%s", option + 6); +#endif + } else if (MATCH_STR(option + 1, "passwd=") == 0) { +#ifdef USE_ATCMDLINE replace_to_blank(option + 8, pvar->ssh2_password, sizeof(pvar->ssh2_password)); //_snprintf(pvar->ssh2_password, sizeof(pvar->ssh2_password), "%s", option + 8); +#else + _snprintf_s(pvar->ssh2_password, sizeof(pvar->ssh2_password), _TRUNCATE, "%s", option + 8); +#endif } else if (MATCH_STR(option + 1, "keyfile=") == 0) { +#ifdef USE_ATCMDLINE replace_to_blank(option + 9, pvar->ssh2_keyfile, sizeof(pvar->ssh2_keyfile)); +#else + _snprintf_s(pvar->ssh2_keyfile, sizeof(pvar->ssh2_keyfile), _TRUNCATE, "%s", option + 9); +#endif } else if (MATCH_STR(option + 1, "ask4passwd") == 0) { // pX[hð· (2006.9.18 maya) @@ -1742,7 +1756,7 @@ static void FAR PASCAL TTXParseParam(PCHAR param, PTTSet ts, PCHAR DDETopic) { -#if 1 +#ifndef USE_ATCMDLINE int i; BOOL inParam = FALSE; BOOL inQuotes = FALSE; @@ -1760,17 +1774,12 @@ if (inQuotes) { // »ÝÊuª"Ì if (param[i] == '"') { -#if 0 -// "ð\·½ßÉ""ðn·dlÉ·éê if (param[i+1] == '"') { - buf[buf_len] = param[i]; - buf_len++; + buf[buflen] = param[i]; + buflen++; i++; } else { -#else - { -#endif // NH[gµÄ¢éƫͱ±ÅIíè // "ðbufÉüê¸ÉðÍÉn· switch (parse_option(pvar, buf)) { @@ -4015,6 +4024,46 @@ } +static void _dquote_string(char *str, char *dst, int dst_len) +{ + int i, len, n; + + len = strlen(str); + n = 0; + for (i = 0 ; i < len ; i++) { + if (str[i] == '"') + n++; + } + if (dst_len < (len + 2*n + 2 + 1)) + return; + + *dst++ = '"'; + for (i = 0 ; i < len ; i++) { + if (str[i] == '"') { + *dst++ = '"'; + *dst++ = '"'; + + } else { + *dst++ = str[i]; + + } + } + *dst++ = '"'; + *dst = '\0'; +} + +static void dquote_string(char *str, char *dst, int dst_len) +{ + // " ÅnÜé©AXy[XªÜÜêéêÉÍNI[g·é + if (str[0] == '"' || strchr(str, '" ') != NULL) { + _dquote_string(str, dst, dst_len); + return; + } + // »ÌÜÜRs[µÄßé + strncpy_s(dst, dst_len, str, _TRUNCATE); +} + +#ifdef USE_ATCMDLINE // ȺÍTeraTerm MenuÌR[h(ttpmenu.cpp)ƯêB // óð @ Éu«·¦éB@©gÍ@@É·éB(2005.1.28 yutaka) static void replace_blank_to_mark(char *str, char *dst, int dst_len) @@ -4046,6 +4095,7 @@ *dst = '\0'; } +#endif static void PASCAL FAR TTXSetCommandLine(PCHAR cmd, int cmdlen, PGetHNRec rec) @@ -4122,25 +4172,41 @@ // pX[hðo¦Ä¢éêÌÝAR}hCÉn·B(2006.8.3 yutaka) if (pvar->settings.remember_password && pvar->auth_state.cur_cred.method == SSH_AUTH_PASSWORD) { +#ifdef USE_ATCMDLINE replace_blank_to_mark(pvar->auth_state.cur_cred.password, mark, sizeof(mark)); +#else + dquote_string(pvar->auth_state.cur_cred.password, mark, sizeof(mark)); +#endif _snprintf_s(tmp, sizeof(tmp), _TRUNCATE, " /auth=password /user=%s /passwd=%s", pvar->auth_state.user, mark); strncat_s(cmd, cmdlen, tmp, _TRUNCATE); } else if (pvar->settings.remember_password && pvar->auth_state.cur_cred.method == SSH_AUTH_RSA) { +#ifdef USE_ATCMDLINE replace_blank_to_mark(pvar->auth_state.cur_cred.password, mark, sizeof(mark)); +#else + dquote_string(pvar->auth_state.cur_cred.password, mark, sizeof(mark)); +#endif _snprintf_s(tmp, sizeof(tmp), _TRUNCATE, " /auth=publickey /user=%s /passwd=%s", pvar->auth_state.user, mark); strncat_s(cmd, cmdlen, tmp, _TRUNCATE); +#ifdef USE_ATCMDLINE replace_blank_to_mark(pvar->session_settings.DefaultRSAPrivateKeyFile, mark, sizeof(mark)); +#else + dquote_string(pvar->session_settings.DefaultRSAPrivateKeyFile, mark, sizeof(mark)); +#endif _snprintf_s(tmp, sizeof(tmp), _TRUNCATE, " /keyfile=%s", mark); strncat_s(cmd, cmdlen, tmp, _TRUNCATE); } else if (pvar->settings.remember_password && pvar->auth_state.cur_cred.method == SSH_AUTH_TIS) { +#ifdef USE_ATCMDLINE replace_blank_to_mark(pvar->auth_state.cur_cred.password, mark, sizeof(mark)); +#else + dquote_string(pvar->auth_state.cur_cred.password, mark, sizeof(mark)); +#endif _snprintf_s(tmp, sizeof(tmp), _TRUNCATE, " /auth=challenge /user=%s /passwd=%s", pvar->auth_state.user, mark); strncat_s(cmd, cmdlen, tmp, _TRUNCATE);