svnno****@sourc*****
svnno****@sourc*****
2013年 3月 9日 (土) 23:37:25 JST
Revision: 5138 http://sourceforge.jp/projects/ttssh2/scm/svn/commits/5138 Author: yutakapon Date: 2013-03-09 23:37:24 +0900 (Sat, 09 Mar 2013) Log Message: ----------- ファイル名の不正文字チェック強化。 Modified Paths: -------------- trunk/teraterm/common/ttlib.c -------------- next part -------------- Modified: trunk/teraterm/common/ttlib.c =================================================================== --- trunk/teraterm/common/ttlib.c 2013-03-06 15:44:00 UTC (rev 5137) +++ trunk/teraterm/common/ttlib.c 2013-03-09 14:37:24 UTC (rev 5138) @@ -18,6 +18,19 @@ // for isInvalidFileNameChar / replaceInvalidFileNameChar static char *invalidFileNameChars = "\\/:*?\"<>|"; +// \x83t\x83@\x83C\x83\x8B\x82Ɏg\x97p\x82\xB7\x82邱\x82Ƃ\xAA\x82ł\xAB\x82Ȃ\xA2\x95\xB6\x8E\x9A +// cf. Naming Files, Paths, and Namespaces +// http://msdn.microsoft.com/en-us/library/aa365247.aspx +// (2013.3.9 yutaka) +static char *invalidFileNameStrings[] = { + "AUX", "CLOCK$", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", + "CON", "CONFIG$", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9", + "NUL", "PRN", + ".", "..", + NULL +}; + + // for b64encode/b64decode static char *b64enc_table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; static char b64dec_table[] = { @@ -438,7 +451,17 @@ int isInvalidFileNameChar(PCHAR FName) { int i, len; + char **p, c; + // \x83`\x83F\x83b\x83N\x91Ώۂ̕\xB6\x8E\x9A\x82\xF0\x8B\xAD\x89\xBB\x82\xB5\x82\xBD\x81B(2013.3.9 yutaka) + p = invalidFileNameStrings; + while (*p) { + if (_strcmpi(FName, *p) == 0) { + return 1; // Invalid + } + p++; + } + len = strlen(FName); for (i=0; i<len; i++) { if (_ismbblead(FName[i])) { @@ -449,6 +472,12 @@ return 1; } } + + // \x83t\x83@\x83C\x83\x8B\x96\xBC\x82̖\x96\x94\xF6\x82Ƀs\x83\x8A\x83I\x83h\x82\xA8\x82\xE6\x82ы\xCDNG\x81B + c = FName[len - 1]; + if (c == '.' || c == ' ') + return 1; + return 0; }