Browse code

improve support for multi-language files

git-svn: trunk@1857

Tomasz Kojm authored on 2006/03/11 23:25:49
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Sat Mar 11 15:23:20 CET 2006 (tk)
2
+---------------------------------
3
+  * libclamav/sis.c: improve support for multi-language files
4
+
1 5
 Fri Mar 10 16:08:25 CET 2006 (tk)
2 6
 ---------------------------------
3 7
   * libclamav/matcher.c: properly handle partial reads in cli_scandesc()
... ...
@@ -32,6 +32,8 @@
32 32
 #include <time.h>
33 33
 #include <zlib.h>
34 34
 
35
+#include "others.h"
36
+
35 37
 #if HAVE_SYS_MMAN_H
36 38
 #include <sys/mman.h>
37 39
 #else /* HAVE_SYS_MMAN_H */
... ...
@@ -40,7 +42,6 @@
40 40
 
41 41
 #include "cltypes.h"
42 42
 #include "clamav.h"
43
-#include "others.h"
44 43
 #include "sis.h"
45 44
 
46 45
 #if WORDS_BIGENDIAN == 0
... ...
@@ -160,11 +161,9 @@ static int sis_extract_simple(int fd, char *mfile, uint32_t length, uint32_t off
160 160
 	case 0x04:
161 161
 	    cli_dbgmsg("SIS: File type: Null file\n");
162 162
 	    return CL_CLEAN;
163
-	    break;
164 163
 	case 0x05:
165 164
 	    cli_dbgmsg("SIS: File type: MIME file\n");
166 165
 	    return CL_CLEAN;
167
-	    break;
168 166
 	default:
169 167
 	    cli_warnmsg("SIS: Unknown file type in file record\n");
170 168
     }
... ...
@@ -233,7 +232,7 @@ static int sis_extract_simple(int fd, char *mfile, uint32_t length, uint32_t off
233 233
 
234 234
     for(i = 0; i < nlangs; i++) {
235 235
 	filelen = cli_readint32(mfile + offset + 24 + 4 * i);
236
-	fileoff = cli_readint32(mfile + offset + 24 + 4 * (i + 1));
236
+	fileoff = cli_readint32(mfile + offset + 24 + 4 * i + 4 * nlangs);
237 237
 
238 238
 	if(filelen >= length || fileoff >= length || filelen + fileoff > length) {
239 239
 	    cli_errmsg("SIS: sis_extract_simple: Broken file data (filelen, fileoff)\n");
... ...
@@ -388,8 +387,12 @@ int cli_scansis(int desc, cli_ctx *ctx)
388 388
 	    cli_dbgmsg("SIS: EPOC release 6\n");
389 389
 	    release = 6;
390 390
 	    break;
391
+	case 0x100039ce:
392
+	case 0x10003a38:
393
+	    cli_dbgmsg("SIS: Application(???)\n");
394
+	    return CL_CLEAN;
391 395
 	default:
392
-	    cli_warnmsg("SIS: Unknown value of UID 2 (EPOC release) -> not a real SIS file??\n");
396
+	    cli_warnmsg("SIS: Unknown value of UID 2 (EPOC release == 0x%x) -> not a real SIS file??\n", EC32(file_hdr.uid2));
393 397
 	    munmap(mfile, length);
394 398
 	    return CL_CLEAN;
395 399
     }
... ...
@@ -546,7 +549,7 @@ int cli_scansis(int desc, cli_ctx *ctx)
546 546
 	switch(cli_readint32(mfile + frecord)) {
547 547
 	    case 0x00000000:
548 548
 		cli_dbgmsg("SIS: Simple file record\n");
549
-		if((ret = sis_extract_simple(desc, mfile, sb.st_size, frecord + 4, nlangs, compressed, dir, ctx))) {
549
+		if((ret = sis_extract_simple(desc, mfile, sb.st_size, frecord + 4, 1, compressed, dir, ctx))) {
550 550
 		    munmap(mfile, length);
551 551
 		    if(!cli_leavetemps_flag)
552 552
 			cli_rmdirs(dir);
... ...
@@ -555,9 +558,9 @@ int cli_scansis(int desc, cli_ctx *ctx)
555 555
 		}
556 556
 
557 557
 		if(release == 6)
558
-		    frecord += 32 + 12 * nlangs + 4;
558
+		    frecord += 32 + 12 + 4;
559 559
 		else
560
-		    frecord += 28 + 4 * nlangs + 4;
560
+		    frecord += 28 + 4 + 4;
561 561
 
562 562
 		break;
563 563
 	    case 0x00000001: