[ttssh2-commit] [10556] TeraTerm Menu 内で組み立てて ttermpro.exe に渡す引数の上限を 8191 文字に変更

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2023年 1月 31日 (火) 21:43:08 JST


Revision: 10556
          https://osdn.net/projects/ttssh2/scm/svn/commits/10556
Author:   nmaya
Date:     2023-01-31 21:43:07 +0900 (Tue, 31 Jan 2023)
Log Message:
-----------
TeraTerm Menu 内で組み立てて ttermpro.exe に渡す引数の上限を 8191 文字に変更

これまでは 259 (MAX_PATH) 文字だった

ticket: #40764

Ticket Links:
------------
    https://osdn.net/projects/ttssh2/tracker/detail/40764

Modified Paths:
--------------
    branches/4-stable/doc/en/html/about/history.html
    branches/4-stable/doc/ja/html/about/history.html
    branches/4-stable/ttpmenu/ttpmenu.cpp

-------------- next part --------------
Modified: branches/4-stable/doc/en/html/about/history.html
===================================================================
--- branches/4-stable/doc/en/html/about/history.html	2023-01-31 12:42:55 UTC (rev 10555)
+++ branches/4-stable/doc/en/html/about/history.html	2023-01-31 12:43:07 UTC (rev 10556)
@@ -78,6 +78,7 @@
     <ul>
       <li>Added about EAR(Export Administration Regulations) to Frequently asked questions.</li>
       <li>upgraded Oniguruma to 6.9.8.</li>
+      <li>upgraded TeraTerm Menu to <a href="#ttmenu_1.17">1.17</a></li>
       <li>upgraded TTXttyrec Plug-in to <a href="#ttyrec_1.05">1.05</a>.</li>
     </ul>
   </li>
@@ -5181,6 +5182,11 @@
 
 <h2 id="ttmenu">TeraTerm Menu</h2>
 
+<h3 id="ttmenu_1.17">2023.xx.xx (Ver 1.17 not released)</h3>
+<ul class="history">
+      <li>TeraTerm Menu can pass an argument that is over 260 bytes to ttermpro.exe now.</li>
+</ul>
+
 <h3 id="ttmenu_1.16">2021.6.5 (Ver 1.16)</h3>
 <ul class="history">
       <li>The tool chip's text of button for registering to the list are changed to "Register" and "Unregister".</li>

Modified: branches/4-stable/doc/ja/html/about/history.html
===================================================================
--- branches/4-stable/doc/ja/html/about/history.html	2023-01-31 12:42:55 UTC (rev 10555)
+++ branches/4-stable/doc/ja/html/about/history.html	2023-01-31 12:43:07 UTC (rev 10556)
@@ -78,6 +78,7 @@
     <ul>
       <li>Q & A\x8FW\x82ɗA\x8Fo\x8BK\x90\xA7(EAR)\x82ɂ‚\xA2\x82ĒNjL\x82\xB5\x82\xBD\x81B</li>
       <li>Oniguruma 6.9.8\x82֍\xB7\x82\xB5\x91ւ\xA6\x82\xBD\x81B</li>
+      <li><a href="#ttmenu_1.17">TeraTerm Menu(1.17)</a>\x82֍\xB7\x82\xB5\x91ւ\xA6\x82\xBD\x81B</li>
       <li><a href="#ttyrec_1.05">TTXttyrec Plugin(1.05)</a>\x82֍\xB7\x82\xB5\x91ւ\xA6\x82\xBD\x81B</li>
     </ul>
   </li>
@@ -5188,6 +5189,11 @@
 
 <h2 id="ttmenu">TeraTerm Menu</h2>
 
+<h3 id="ttmenu_1.17">2023.xx.xx (Ver 1.17 not released)</h3>
+<ul class="history">
+      <li>260 \x95\xB6\x8E\x9A\x88ȏ\xE3\x82̈\xF8\x90\x94\x82\xF0 ttermpro.exe \x82ɓn\x82\xB9\x82\xE9\x82悤\x82ɂ\xB5\x82\xBD\x81B</li>
+</ul>
+
 <h3 id="ttmenu_1.16">2021.6.5 (Ver 1.16)</h3>
 <ul class="history">
       <li>\x83\x8A\x83X\x83g\x82֓o\x98^\x82\xB7\x82\xE9\x83{\x83^\x83\x93\x82̃c\x81[\x83\x8B\x83`\x83b\x83v\x82̕\xB6\x8C\xBE\x82\xF0Register, Unregister\x82ɕύX\x82\xB5\x82\xBD\x81B</li>

Modified: branches/4-stable/ttpmenu/ttpmenu.cpp
===================================================================
--- branches/4-stable/ttpmenu/ttpmenu.cpp	2023-01-31 12:42:55 UTC (rev 10555)
+++ branches/4-stable/ttpmenu/ttpmenu.cpp	2023-01-31 12:43:07 UTC (rev 10556)
@@ -11,6 +11,7 @@
 #include	<windows.h>
 #include	<commctrl.h>
 #include	<windowsx.h>  // for GET_X_LPARAM(), GET_Y_LPARAM()
+#include	<string.h>
 
 #include	"ttpmenu.h"
 #include	"registry.h"
@@ -20,8 +21,7 @@
 #include	"compat_w95.h"
 #include	"ttlib.h"
 
-// UTF-8 TeraTerm\x82ł́A\x83f\x83t\x83H\x83\x8B\x83g\x83C\x83\x93\x83X\x83g\x81[\x83\x8B\x90\xE6\x82\xF0\x89\xBA\x8BL\x82ɕύX\x82\xB5\x82\xBD\x81B(2004.12.2 yutaka)
-// \x82\xB3\x82\xE7\x82ɁA\x83f\x83t\x83H\x83\x8B\x83g\x83C\x83\x93\x83X\x83g\x81[\x83\x8B\x90\xE6\x82̓J\x83\x8C\x83\x93\x83g\x83f\x83B\x83\x8C\x83N\x83g\x83\x8A\x82ɕύX\x81B(2004.12.14 yutaka)
+// \x83f\x83t\x83H\x83\x8B\x83g\x83C\x83\x93\x83X\x83g\x81[\x83\x8B\x90\xE6\x82̓J\x83\x8C\x83\x93\x83g\x83f\x83B\x83\x8C\x83N\x83g\x83\x8A
 #define DEFAULT_PATH "."
 
 // \x83O\x83\x8D\x81[\x83o\x83\x8B\x95ϐ\x94
@@ -1199,7 +1199,9 @@
 	char	szHostName[MAX_PATH];
 	char	szTempPath[MAX_PATH];
 	char	szMacroFile[MAX_PATH];
-	char	szArgment[MAX_PATH] = "";
+	// https://learn.microsoft.com/en-us/troubleshoot/windows-client/shell-experience/command-line-string-limitation
+	char	szArgment[8192] = "";
+	char	szTemp[8192];
 	char	*pHostName;
 	TCHAR	*pt;
 	JobInfo	jobInfo;
@@ -1231,8 +1233,10 @@
 		pHostName = szHostName;
 
 	if (jobInfo.dwMode != MODE_DIRECT)
-		if (::lstrlen(jobInfo.szInitFile) != 0)
-			::wsprintf(szArgment, "/F=\"%s\"", jobInfo.szInitFile);
+		if (::lstrlen(jobInfo.szInitFile) != 0) {
+			_snprintf_s(szTemp, sizeof(szTemp),  _TRUNCATE, "/F=\"%s\"", jobInfo.szInitFile);
+			strncat_s(szArgment, sizeof(szArgment), szTemp, _TRUNCATE);
+		}
 
 	switch (jobInfo.dwMode) {
 	case MODE_AUTOLOGIN:
@@ -1251,59 +1255,62 @@
 		break;
 	}
 
-	// SSH\x8E\xA9\x93\xAE\x83\x8D\x83O\x83C\x83\x93\x82̏ꍇ\x82̓}\x83N\x83\x8D\x82͕s\x97v (2005.1.25 yutaka)
+	// SSH\x8E\xA9\x93\xAE\x83\x8D\x83O\x83C\x83\x93\x82̏ꍇ\x82̓}\x83N\x83\x8D\x82͕s\x97v
 	if (jobInfo.bTtssh != TRUE) {
-		if (jobInfo.dwMode != MODE_DIRECT)
-			::wsprintf(szArgment, "%s /M=\"%s\"", szArgment, szMacroFile);
+		if (jobInfo.dwMode != MODE_DIRECT) {
+			_snprintf_s(szTemp, sizeof(szTemp),  _TRUNCATE, " /M=\"%s\"", szMacroFile);
+			strncat_s(szArgment, sizeof(szArgment), szTemp, _TRUNCATE);
+		}
 	}
 
-	if (::lstrlen(jobInfo.szOption) != 0)
-		::wsprintf(szArgment, "%s %s", szArgment, jobInfo.szOption);
+	if (::lstrlen(jobInfo.szOption) != 0) {
+		_snprintf_s(szTemp, sizeof(szTemp),  _TRUNCATE, " %s", jobInfo.szOption);
+		strncat_s(szArgment, sizeof(szArgment), szTemp, _TRUNCATE);
+	}
 
-	// TTSSH\x82\xAA\x97L\x8C\xF8\x82̏ꍇ\x82́A\x8E\xA9\x93\xAE\x83\x8D\x83O\x83C\x83\x93\x82̂\xBD\x82߂̃R\x83}\x83\x93\x83h\x83\x89\x83C\x83\x93\x82\xF0\x95t\x89\xC1\x82\xB7\x82\xE9\x81B(2004.12.3 yutaka)
-	// \x83\x86\x81[\x83U\x82̃p\x83\x89\x83\x81\x81[\x83^\x82\xF0\x8Ew\x92\xE8\x82ł\xAB\x82\xE9\x82悤\x82ɂ\xB7\x82\xE9 (2005.1.25 yutaka)
-	// \x8C\xF6\x8AJ\x8C\xAE\x94F\x8F؂\xF0\x83T\x83|\x81[\x83g (2005.1.27 yutaka)
-	// /challenge\x82\xF0\x83T\x83|\x81[\x83g (2007.11.14 yutaka)
-	// /pageant\x82\xF0\x83T\x83|\x81[\x83g (2008.5.26 maya)
+	// TTSSH\x82\xAA\x97L\x8C\xF8\x82̏ꍇ\x82́A\x8E\xA9\x93\xAE\x83\x8D\x83O\x83C\x83\x93\x82̂\xBD\x82߂̃R\x83}\x83\x93\x83h\x83\x89\x83C\x83\x93\x82\xF0\x95t\x89\xC1\x82\xB7\x82\xE9\x81B
 	if (jobInfo.dwMode == MODE_AUTOLOGIN) {
 		if (jobInfo.bTtssh == TRUE) {
-			char tmp[MAX_PATH];
 			char passwd[MAX_PATH], keyfile[MAX_PATH];
 
-			strcpy(tmp, szArgment);
+			strncpy_s(szTemp, sizeof(szTemp), szArgment, _TRUNCATE);
 			dquote_string(jobInfo.szPassword, passwd, sizeof(passwd));
 			dquote_string(jobInfo.PrivateKeyFile, keyfile, sizeof(keyfile));
 
 			if (jobInfo.bChallenge) { // keyboard-interactive
-				_snprintf(szArgment, sizeof(szArgment), "%s:22 /ssh /auth=challenge /user=%s /passwd=%s %s", 
+				_snprintf_s(szArgment, sizeof(szArgment), _TRUNCATE,
+					"%s:22 /ssh /auth=challenge /user=%s /passwd=%s %s", 
 					jobInfo.szHostName,
 					jobInfo.szUsername,
 					passwd,
-					tmp
+					szTemp
 					);
 
 			} else if (jobInfo.bPageant) { // Pageant
-				_snprintf(szArgment, sizeof(szArgment), "%s:22 /ssh /auth=pageant /user=%s %s", 
+				_snprintf_s(szArgment, sizeof(szArgment), _TRUNCATE,
+					"%s:22 /ssh /auth=pageant /user=%s %s", 
 					jobInfo.szHostName,
 					jobInfo.szUsername,
-					tmp
+					szTemp
 					);
 
 			} else if (jobInfo.PrivateKeyFile[0] == NULL) { // password authentication
-				_snprintf(szArgment, sizeof(szArgment), "%s:22 /ssh /auth=password /user=%s /passwd=%s %s", 
+				_snprintf_s(szArgment, sizeof(szArgment), _TRUNCATE,
+					"%s:22 /ssh /auth=password /user=%s /passwd=%s %s", 
 					jobInfo.szHostName,
 					jobInfo.szUsername,
 					passwd,
-					tmp
+					szTemp
 					);
 
 			} else { // publickey
-				_snprintf(szArgment, sizeof(szArgment), "%s:22 /ssh /auth=publickey /user=%s /passwd=%s /keyfile=%s %s", 
+				_snprintf_s(szArgment, sizeof(szArgment), _TRUNCATE,
+					"%s:22 /ssh /auth=publickey /user=%s /passwd=%s /keyfile=%s %s", 
 					jobInfo.szHostName,
 					jobInfo.szUsername,
 					passwd,
 					keyfile,
-					tmp
+					szTemp
 					);
 
 			}
@@ -1310,7 +1317,7 @@
 
 		} else {
 			// SSH\x82\xF0\x8Eg\x82\xED\x82Ȃ\xA2\x8Fꍇ\x81A/nossh \x83I\x83v\x83V\x83\x87\x83\x93\x82\xF0\x95t\x82\xAF\x82Ă\xA8\x82\xAD\x81B
-			::wsprintf(szArgment, "%s /nossh", szArgment);
+			strncpy_s(szArgment, sizeof(szArgment), " /nossh", _TRUNCATE);
 		}
 	}
 
@@ -1780,7 +1787,6 @@
 		}
 	}
 
-	// \x94閧\x8C\xAE\x83t\x83@\x83C\x83\x8B\x82̒lj\xC1 (2005.1.28 yutaka)
 	if (::GetDlgItemText(hWnd, IDC_KEYFILE_PATH, g_JobInfo.PrivateKeyFile, MAX_PATH) == 0) {
 		ZeroMemory(g_JobInfo.PrivateKeyFile, sizeof(g_JobInfo.PrivateKeyFile));
 	}
@@ -1926,13 +1932,6 @@
 
 	}
 
-	// ttssh.exe\x82͔p\x8E~\x82\xB5\x82\xBD\x82̂ʼn\xBA\x8BL\x83`\x83F\x83b\x83N\x82͍폜\x82\xB7\x82\xE9\x81B(2004.12.3 yutaka)
-#if 0
-	if ((pt = lstrstri(g_JobInfo.szTeraTerm, TTSSH)) != NULL)
-		if (::lstrcmpi(pt, TTSSH) == 0)
-			::CheckDlgButton(hWnd, CHECK_TTSSH, TRUE);
-#endif
-
 	::CheckDlgButton(hWnd, CHECK_STARTUP, g_JobInfo.bStartup);
 
 	return TRUE;


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