svnno****@sourc*****
svnno****@sourc*****
2012年 3月 10日 (土) 00:25:48 JST
Revision: 4858 http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=4858 Author: yutakapon Date: 2012-03-10 00:25:48 +0900 (Sat, 10 Mar 2012) Log Message: ----------- 名前付きパイプの書式チェックを追加した。 \\ServerName\pipe\PipeName Modified Paths: -------------- trunk/teraterm/teraterm/commlib.c -------------- next part -------------- Modified: trunk/teraterm/teraterm/commlib.c =================================================================== --- trunk/teraterm/teraterm/commlib.c 2012-03-08 15:50:26 UTC (rev 4857) +++ trunk/teraterm/teraterm/commlib.c 2012-03-09 15:25:48 UTC (rev 4858) @@ -554,15 +554,39 @@ case IdNamedPipe: InitFileIO(IdNamedPipe); /* TTPLUG */ TTXOpenFile(); /* TTPLUG */ + + memset(P, 0, sizeof(P)); strncpy_s(P, sizeof(P), ts->HostName, _TRUNCATE); + + // \x96\xBC\x91O\x95t\x82\xAB\x83p\x83C\x83v\x82\xAA\x90\xB3\x82\xB5\x82\xA2\x8F\x91\x8E\xAE\x82\xA9\x82\xF0\x83`\x83F\x83b\x83N\x82\xB7\x82\xE9\x81B + // \\ServerName\pipe\PipeName + // (2012.3.10 yutaka) + InvalidHost = TRUE; + if (P[0] == '\\' && P[1] == '\\') { + char *s = strchr(&P[2], '\\'); + if (s && _strnicmp(s+1, "pipe\\", 5) == 0) { + InvalidHost = FALSE; + } + } + if (InvalidHost) { + _snprintf_s(ErrMsg, sizeof(ErrMsg), _TRUNCATE, + "Invalid pipe name\n[%s]\n" + "A valid pipe name has the form\n" + "\"\\\\<ServerName\\pipe\\<PipeName>\"", + &P[0], GetLastError()); + get_lang_msg("MSG_TT_ERROR", uimsg, sizeof(uimsg), "Tera Term: Error", ts->UILanguageFile); + MessageBox(cv->HWin,ErrMsg,uimsg,MB_TASKMODAL | MB_ICONEXCLAMATION); + break; + } + cv->ComID = PCreateFile(P,GENERIC_READ | GENERIC_WRITE, 0,NULL,OPEN_EXISTING, 0, // \x83u\x83\x8D\x83b\x83L\x83\x93\x83O\x83\x82\x81[\x83h\x82ɂ\xB7\x82\xE9(FILE_FLAG_OVERLAPPED \x82͎w\x92肵\x82Ȃ\xA2) NULL); if (cv->ComID == INVALID_HANDLE_VALUE ) { - get_lang_msg("MSG_CANTOEPN_ERROR", ts->UIMsg, sizeof(ts->UIMsg), "Cannot open %s(%d)", ts->UILanguageFile); - _snprintf_s(ErrMsg, sizeof(ErrMsg), _TRUNCATE, ts->UIMsg, &P[0], GetLastError()); + get_lang_msg("MSG_CANTOEPN_ERROR", ts->UIMsg, sizeof(ts->UIMsg), "Cannot open %s", ts->UILanguageFile); + _snprintf_s(ErrMsg, sizeof(ErrMsg), _TRUNCATE, ts->UIMsg, &P[4]); if (cv->NoMsg==0) { get_lang_msg("MSG_TT_ERROR", uimsg, sizeof(uimsg), "Tera Term: Error", ts->UILanguageFile);