Browse code

libclamav: fix scanning of utf16 data (bb#1853)

Tomasz Kojm authored on 2010/03/06 06:01:48
Showing 3 changed files
... ...
@@ -1,3 +1,7 @@
1
+Fri Mar  5 22:01:20 CET 2010 (tk)
2
+---------------------------------
3
+ * libclamav: fix scanning of utf16 data (bb#1853)
4
+
1 5
 Fri Mar  5 21:14:12 CET 2010 (tk)
2 6
 ---------------------------------
3 7
  * libclamav/matcher-bm.c: properly handle scan boundaries in
... ...
@@ -186,7 +186,7 @@ cli_file_t cli_filetype2(fmap_t *map, const struct cl_engine *engine)
186 186
 
187 187
 	    decoded = (unsigned char *) cli_utf16toascii((char *) buff, bread);
188 188
 	    if(decoded) {
189
-		sret = cli_ac_scanbuff(decoded, strlen((char *) decoded), NULL, NULL, NULL,  engine->root[0], &mdata, 0, CL_TYPE_TEXT_ASCII, NULL, AC_SCAN_FT, NULL);
189
+		sret = cli_ac_scanbuff(decoded, bread / 2, NULL, NULL, NULL,  engine->root[0], &mdata, 0, CL_TYPE_TEXT_ASCII, NULL, AC_SCAN_FT, NULL);
190 190
 		free(decoded);
191 191
 		if(sret == CL_TYPE_HTML)
192 192
 		    ret = CL_TYPE_HTML_UTF16;
... ...
@@ -1138,7 +1138,7 @@ static int cli_scanhtml_utf16(cli_ctx *ctx)
1138 1138
 	at += bytes;
1139 1139
 	decoded = cli_utf16toascii(buff, bytes);
1140 1140
 	if(decoded) {
1141
-	    if(write(fd, decoded, strlen(decoded)) == -1) {
1141
+	    if(write(fd, decoded, bytes / 2) == -1) {
1142 1142
 		cli_errmsg("cli_scanhtml_utf16: Can't write to file %s\n", tempname);
1143 1143
 		free(decoded);
1144 1144
 		close(fd);