[Ttssh2-commit] [6878] 文字列に 0x01 が含まれる場合の対処を追加

svnno****@sourc***** svnno****@sourc*****
2017年 7月 24日 (月) 23:13:49 JST


Revision: 6878
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/6878
Author:   doda
Date:     2017-07-24 23:13:49 +0900 (Mon, 24 Jul 2017)
Log Message:
-----------
文字列に 0x01 が含まれる場合の対処を追加

Modified Paths:
--------------
    trunk/teraterm/ttpmacro/ttl.c
    trunk/tests/#37048-sendmulticast.ttl

-------------- next part --------------
Modified: trunk/teraterm/ttpmacro/ttl.c
===================================================================
--- trunk/teraterm/ttpmacro/ttl.c	2017-07-24 14:13:46 UTC (rev 6877)
+++ trunk/teraterm/ttpmacro/ttl.c	2017-07-24 14:13:49 UTC (rev 6878)
@@ -3983,6 +3983,38 @@
 }
 
 /*
+ * src \x82Ɋ܂܂\xEA\x82\xE9 0x01 \x82\xF0 0x01 0x02 \x82ɒu\x82\xAB\x8A\xB7\x82\xA6\x82\xC4 dst \x82ɃR\x83s\x81[\x82\xB7\x82\xE9\x81B
+ * TStrVal \x82ɂ\xCD 0x00 \x82\xAA\x8A܂܂\xEA\x82鎖\x82\xAA\x96\xB3\x82\xA2(\x8FI\x92[\x82Ƌ\xE6\x95ʂł\xAB\x82Ȃ\xA2)\x82̂\xC5 0x00 \x82͍l\x97\xB6\x82\xB7\x82\xE9\x95K\x97v\x82Ȃ\xB5\x81B
+ */
+static void AddBroadcastString(char *dst, int dstlen, char *src)
+{
+	int i;
+	char *p, *p2;
+
+	i = strlen(dst);
+	dst += i;
+	dstlen -= i;
+
+	while (*src != 0 && dstlen > 1) {
+		if (*src == 0x01) {
+			// 0x01 \x82\xF0\x8Ai\x94[\x82\xB7\x82\xE9\x82ɂ\xCD 0x01 0x02 \x82\xCC2\x83o\x83C\x83g + NUL \x8FI\x92[\x97p\x82\xCC1\x83o\x83C\x83g\x82\xAA\x95K\x97v
+			if (dstlen < 3) {
+				break;
+			}
+			*dst++ = *src++;
+			*dst++ = 0x02;
+			dstlen -= 2;
+		}
+		else {
+			*dst++ = *src++;
+			dstlen--;
+		}
+	}
+
+	*dst = 0;
+}
+
+/*
  * TTLSendBroadcast / TTLSendMulticast \x82̉\xBA\x90\xBF\x82\xAF
  *
  * \x8Ae\x83p\x83\x89\x83\x81\x81[\x83^\x82\xF0\x98A\x8C\x8B\x82\xB5\x82\xBD\x95\xB6\x8E\x9A\x97\xF1\x82\xF0 buff \x82Ɋi\x94[\x82\xB5\x82ĕԂ\xB7\x81B
@@ -4005,7 +4037,7 @@
 	while (1) {
 		if (GetString(Str, &Err)) {
 			if (Err!=0) return Err;
-			strncat_s(buff, bufflen, Str, _TRUNCATE);
+			AddBroadcastString(buff, bufflen, Str);
 		}
 		else if (GetExpression(&ValType, &Val, &Err)) {
 			if (Err!=0) return Err;
@@ -4024,7 +4056,7 @@
 					strncat_s(buff, bufflen, tmp, _TRUNCATE);
 					break;
 				case TypString: 
-					strncat_s(buff, bufflen, StrVarPtr((TVarId)Val), _TRUNCATE);
+					AddBroadcastString(buff, bufflen, StrVarPtr((TVarId)Val));
 					break;
 				default:
 					return ErrTypeMismatch;

Modified: trunk/tests/#37048-sendmulticast.ttl
===================================================================
--- trunk/tests/#37048-sendmulticast.ttl	2017-07-24 14:13:46 UTC (rev 6877)
+++ trunk/tests/#37048-sendmulticast.ttl	2017-07-24 14:13:49 UTC (rev 6878)
@@ -13,8 +13,17 @@
 
 sendmulticast mcast "0: " 0 ", 1:" 1 ","#13#10
 
+;pause 1
+
+sendmulticast mcast "1:"#1","#13#10
+
 pause 1
 
+str = "1:"#1","#13#10
+sendmulticast mcast str
+
+pause 1
+
 sendmulticast mcast 4
 end
 



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