git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@1407 77e5149b-7576-45b1-b177-96237e5ba77b
Tomasz Kojm authored on 2005/03/19 06:06:25... | ... |
@@ -122,7 +122,8 @@ struct cli_md5_node { |
122 | 122 |
}; |
123 | 123 |
|
124 | 124 |
struct cli_meta_node { |
125 |
- int method, csize, size, encrypted, crc32, fileno, maxdepth; |
|
125 |
+ int csize, size; |
|
126 |
+ unsigned int crc32, fileno, method, encrypted, maxdepth; |
|
126 | 127 |
char *filename, *virname; |
127 | 128 |
struct cli_meta_node *next; |
128 | 129 |
}; |
... | ... |
@@ -151,15 +152,15 @@ struct cl_node { |
151 | 151 |
}; |
152 | 152 |
|
153 | 153 |
struct cl_limits { |
154 |
- int maxreclevel; /* maximal recursion level */ |
|
155 |
- int maxfiles; /* maximal number of files to be |
|
156 |
- * scanned within an archive |
|
157 |
- */ |
|
158 |
- int maxratio; /* maximal compression ratio */ |
|
159 |
- short archivememlim; /* limit memory usage for bzip2 (0/1) */ |
|
160 |
- long int maxfilesize; /* files in an archive larger than |
|
161 |
- * this value will not be scanned |
|
162 |
- */ |
|
154 |
+ unsigned int maxreclevel; /* maximal recursion level */ |
|
155 |
+ unsigned int maxfiles; /* maximal number of files to be |
|
156 |
+ * scanned within an archive |
|
157 |
+ */ |
|
158 |
+ unsigned int maxratio; /* maximal compression ratio */ |
|
159 |
+ unsigned short archivememlim; /* limit memory usage for bzip2 (0/1) */ |
|
160 |
+ unsigned long int maxfilesize; /* files in an archive larger than |
|
161 |
+ * this limit will not be scanned |
|
162 |
+ */ |
|
163 | 163 |
}; |
164 | 164 |
|
165 | 165 |
struct cl_stat { |
... | ... |
@@ -82,7 +82,7 @@ static int doubledl(char **scur, uint8_t *mydlptr, char *buffer, int buffersize) |
82 | 82 |
|
83 | 83 |
static int unfsg(char *source, char *dest, int ssize, int dsize, char **endsrc, char **enddst) { |
84 | 84 |
uint8_t mydl=0x80; |
85 |
- uint32_t backbytes, backsize, oldback; |
|
85 |
+ uint32_t backbytes, backsize, oldback = 0; |
|
86 | 86 |
char *csrc = source, *cdst = dest; |
87 | 87 |
int oob, lostbit = 1; |
88 | 88 |
|
... | ... |
@@ -227,7 +227,7 @@ void cli_ac_free(struct cl_node *root) |
227 | 227 |
free(root->ac_root); |
228 | 228 |
} |
229 | 229 |
|
230 |
-static int inline cli_findpos(const char *buffer, int offset, int length, const struct cli_ac_patt *pattern) |
|
230 |
+inline static int cli_findpos(const char *buffer, int offset, int length, const struct cli_ac_patt *pattern) |
|
231 | 231 |
{ |
232 | 232 |
int bufferpos = offset + AC_MIN_LENGTH; |
233 | 233 |
int postfixend = offset + length; |
... | ... |
@@ -78,7 +78,7 @@ int cli_bm_addpatt(struct cl_node *root, struct cli_bm_patt *pattern) |
78 | 78 |
|
79 | 79 |
int cli_bm_init(struct cl_node *root) |
80 | 80 |
{ |
81 |
- int i; |
|
81 |
+ unsigned int i; |
|
82 | 82 |
unsigned int size = DHASH(256, 256, 256); |
83 | 83 |
|
84 | 84 |
|
... | ... |
@@ -102,7 +102,7 @@ int cli_bm_init(struct cl_node *root) |
102 | 102 |
void cli_bm_free(struct cl_node *root) |
103 | 103 |
{ |
104 | 104 |
struct cli_bm_patt *b1, *b2; |
105 |
- int i; |
|
105 |
+ unsigned int i; |
|
106 | 106 |
unsigned int size = DHASH(256, 256, 256); |
107 | 107 |
|
108 | 108 |
|
... | ... |
@@ -130,7 +130,7 @@ void cli_bm_free(struct cl_node *root) |
130 | 130 |
|
131 | 131 |
int cli_bm_scanbuff(const char *buffer, unsigned int length, const char **virname, const struct cl_node *root, unsigned long int offset, unsigned short ftype, int fd) |
132 | 132 |
{ |
133 |
- int i, j, shift, off, found = 0; |
|
133 |
+ unsigned int i, j, shift, off, found = 0; |
|
134 | 134 |
uint16_t idx; |
135 | 135 |
struct cli_bm_patt *p; |
136 | 136 |
const char *bp; |
... | ... |
@@ -172,7 +172,7 @@ int cli_checkfp(int fd, const struct cl_node *root) |
172 | 172 |
if(fstat(fd, &sb)) |
173 | 173 |
return CL_EIO; |
174 | 174 |
|
175 |
- if(sb.st_size != md5_node->size) { |
|
175 |
+ if((unsigned int) sb.st_size != md5_node->size) { |
|
176 | 176 |
cli_warnmsg("Detected false positive MD5 match. Please report.\n"); |
177 | 177 |
} else { |
178 | 178 |
cli_dbgmsg("Eliminated false positive match (fp sig: %s)\n", md5_node->virname); |
... | ... |
@@ -212,7 +212,7 @@ int cli_validatesig(unsigned short target, unsigned short ftype, const char *off |
212 | 212 |
return 0; |
213 | 213 |
} |
214 | 214 |
|
215 |
- if(fileoff != off) { |
|
215 |
+ if(fileoff != (unsigned long int) off) { |
|
216 | 216 |
cli_dbgmsg("Virus offset: %d, expected: %d (%s)\n", fileoff, off, virname); |
217 | 217 |
return 0; |
218 | 218 |
} |
... | ... |
@@ -347,7 +347,7 @@ int cli_scandesc(int desc, const char **virname, long int *scanned, const struct |
347 | 347 |
if(fstat(desc, &sb)) |
348 | 348 |
return CL_EIO; |
349 | 349 |
|
350 |
- if(sb.st_size != md5_node->size) { |
|
350 |
+ if((unsigned int) sb.st_size != md5_node->size) { |
|
351 | 351 |
cli_warnmsg("Detected false positive MD5 match. Please report.\n"); |
352 | 352 |
} else { |
353 | 353 |
if(virname) |
... | ... |
@@ -70,7 +70,7 @@ static inline uint32_t EC32(uint32_t v) |
70 | 70 |
|
71 | 71 |
extern short cli_leavetemps_flag; |
72 | 72 |
|
73 |
-static uint32_t cli_rawaddr(uint32_t rva, struct pe_image_section_hdr *shp, uint16_t nos) |
|
73 |
+static uint32_t cli_rawaddr(uint32_t rva, struct pe_image_section_hdr *shp, uint16_t nos, unsigned int *err) |
|
74 | 74 |
{ |
75 | 75 |
int i, found = 0; |
76 | 76 |
|
... | ... |
@@ -84,12 +84,15 @@ static uint32_t cli_rawaddr(uint32_t rva, struct pe_image_section_hdr *shp, uint |
84 | 84 |
|
85 | 85 |
if(!found) { |
86 | 86 |
cli_dbgmsg("Can't calculate raw address from RVA 0x%x\n", rva); |
87 |
- return -1; |
|
87 |
+ *err = 1; |
|
88 |
+ return 0; |
|
88 | 89 |
} |
89 | 90 |
|
91 |
+ *err = 0; |
|
90 | 92 |
return rva - EC32(shp[i].VirtualAddress) + EC32(shp[i].PointerToRawData); |
91 | 93 |
} |
92 | 94 |
|
95 |
+/* |
|
93 | 96 |
static int cli_ddump(int desc, int offset, int size, const char *file) |
94 | 97 |
{ |
95 | 98 |
int pos, ndesc, bread, sum = 0; |
... | ... |
@@ -141,8 +144,9 @@ static int cli_ddump(int desc, int offset, int size, const char *file) |
141 | 141 |
lseek(desc, pos, SEEK_SET); |
142 | 142 |
return 0; |
143 | 143 |
} |
144 |
+*/ |
|
144 | 145 |
|
145 |
-int cli_scanpe(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec) |
|
146 |
+int cli_scanpe(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, unsigned int arec, unsigned int mrec) |
|
146 | 147 |
{ |
147 | 148 |
uint16_t e_magic; /* DOS signature ("MZ") */ |
148 | 149 |
uint16_t nsections; |
... | ... |
@@ -154,10 +158,11 @@ int cli_scanpe(int desc, const char **virname, long int *scanned, const struct c |
154 | 154 |
struct pe_image_section_hdr *section_hdr; |
155 | 155 |
struct stat sb; |
156 | 156 |
char sname[9], buff[4096], *tempfile; |
157 |
- int i, found, upx_success = 0, min = 0, max = 0, ret; |
|
157 |
+ unsigned int i, found, upx_success = 0, min = 0, max = 0, err; |
|
158 |
+ unsigned int ssize = 0, dsize = 0; |
|
158 | 159 |
int (*upxfn)(char *, int , char *, int *, uint32_t, uint32_t, uint32_t) = NULL; |
159 | 160 |
char *src = NULL, *dest = NULL; |
160 |
- int ssize = -1, dsize = -1, ndesc; |
|
161 |
+ int ndesc, ret; |
|
161 | 162 |
|
162 | 163 |
|
163 | 164 |
if(read(desc, &e_magic, sizeof(e_magic)) != sizeof(e_magic)) { |
... | ... |
@@ -410,7 +415,7 @@ int cli_scanpe(int desc, const char **virname, long int *scanned, const struct c |
410 | 410 |
cli_dbgmsg("Section's memory is executable\n"); |
411 | 411 |
cli_dbgmsg("------------------------------------\n"); |
412 | 412 |
|
413 |
- if(EC32(section_hdr[i].PointerToRawData) + EC32(section_hdr[i].SizeOfRawData) > sb.st_size) { |
|
413 |
+ if(EC32(section_hdr[i].PointerToRawData) + EC32(section_hdr[i].SizeOfRawData) > (unsigned long int) sb.st_size) { |
|
414 | 414 |
cli_dbgmsg("Possibly broken PE file - Section %d out of file (Offset@ %d, Rsize %d, Total filesize %d)\n", i, EC32(section_hdr[i].PointerToRawData), EC32(section_hdr[i].SizeOfRawData), sb.st_size); |
415 | 415 |
free(section_hdr); |
416 | 416 |
if(DETECT_BROKEN) { |
... | ... |
@@ -434,7 +439,7 @@ int cli_scanpe(int desc, const char **virname, long int *scanned, const struct c |
434 | 434 |
|
435 | 435 |
} |
436 | 436 |
|
437 |
- if((ep = EC32(optional_hdr.AddressOfEntryPoint)) >= min && (ep = cli_rawaddr(EC32(optional_hdr.AddressOfEntryPoint), section_hdr, nsections)) == -1) { |
|
437 |
+ if((ep = EC32(optional_hdr.AddressOfEntryPoint)) >= min && !(ep = cli_rawaddr(EC32(optional_hdr.AddressOfEntryPoint), section_hdr, nsections, &err)) && err) { |
|
438 | 438 |
cli_dbgmsg("Possibly broken PE file\n"); |
439 | 439 |
free(section_hdr); |
440 | 440 |
if(DETECT_BROKEN) { |
... | ... |
@@ -471,7 +476,7 @@ int cli_scanpe(int desc, const char **virname, long int *scanned, const struct c |
471 | 471 |
|
472 | 472 |
/* try to find the first section with physical size == 0 */ |
473 | 473 |
found = 0; |
474 |
- for(i = 0; i < nsections - 1; i++) { |
|
474 |
+ for(i = 0; i < (unsigned int) nsections - 1; i++) { |
|
475 | 475 |
if(!section_hdr[i].SizeOfRawData && section_hdr[i].VirtualSize && section_hdr[i + 1].SizeOfRawData && section_hdr[i + 1].VirtualSize) { |
476 | 476 |
found = 1; |
477 | 477 |
cli_dbgmsg("UPX/FSG: empty section found - assuming compression\n"); |
... | ... |
@@ -528,14 +533,14 @@ int cli_scanpe(int desc, const char **virname, long int *scanned, const struct c |
528 | 528 |
} |
529 | 529 |
|
530 | 530 |
lseek(desc, EC32(section_hdr[i + 1].PointerToRawData), SEEK_SET); |
531 |
- if(read(desc, src, ssize) != ssize) { |
|
531 |
+ if((unsigned int) read(desc, src, ssize) != ssize) { |
|
532 | 532 |
cli_dbgmsg("Can't read raw data of section %d\n", i); |
533 | 533 |
free(section_hdr); |
534 | 534 |
free(src); |
535 | 535 |
return CL_EIO; |
536 | 536 |
} |
537 | 537 |
|
538 |
- if((newedx - EC32(section_hdr[i + 1].VirtualAddress)) < 0 || ((dest = src + newedx - EC32(section_hdr[i + 1].VirtualAddress)) < src && dest >= src + EC32(section_hdr[i + 1].VirtualAddress) + EC32(section_hdr[i + 1].SizeOfRawData) - 4)) { |
|
538 |
+ if(newedx < EC32(section_hdr[i + 1].VirtualAddress) || ((dest = src + newedx - EC32(section_hdr[i + 1].VirtualAddress)) < src && dest >= src + EC32(section_hdr[i + 1].VirtualAddress) + EC32(section_hdr[i + 1].SizeOfRawData) - 4)) { |
|
539 | 539 |
cli_dbgmsg("FSG: New ESP out of bounds\n"); |
540 | 540 |
free(src); |
541 | 541 |
break; |
... | ... |
@@ -624,7 +629,7 @@ int cli_scanpe(int desc, const char **virname, long int *scanned, const struct c |
624 | 624 |
return CL_CLEAN; |
625 | 625 |
} |
626 | 626 |
|
627 |
- if((gp = cli_readint32(buff + 1) - EC32(optional_hdr.ImageBase)) >= EC32(section_hdr[i + 1].PointerToRawData) || gp < 0) { |
|
627 |
+ if((gp = cli_readint32(buff + 1) - EC32(optional_hdr.ImageBase)) >= (int) EC32(section_hdr[i + 1].PointerToRawData) || gp < 0) { |
|
628 | 628 |
cli_dbgmsg("FSG: Support data out of padding area (vaddr: %d)\n", EC32(section_hdr[i].VirtualAddress)); |
629 | 629 |
break; |
630 | 630 |
} |
... | ... |
@@ -632,7 +637,7 @@ int cli_scanpe(int desc, const char **virname, long int *scanned, const struct c |
632 | 632 |
lseek(desc, gp, SEEK_SET); |
633 | 633 |
gp = EC32(section_hdr[i + 1].PointerToRawData) - gp; |
634 | 634 |
|
635 |
- if(limits && limits->maxfilesize && gp > limits->maxfilesize) { |
|
635 |
+ if(limits && limits->maxfilesize && (unsigned int) gp > limits->maxfilesize) { |
|
636 | 636 |
cli_dbgmsg("FSG: Buffer size exceeded (size: %d, max: %lu)\n", gp, limits->maxfilesize); |
637 | 637 |
free(section_hdr); |
638 | 638 |
return CL_CLEAN; |
... | ... |
@@ -710,7 +715,7 @@ int cli_scanpe(int desc, const char **virname, long int *scanned, const struct c |
710 | 710 |
} |
711 | 711 |
|
712 | 712 |
lseek(desc, EC32(section_hdr[i + 1].PointerToRawData), SEEK_SET); |
713 |
- if(read(desc, src, ssize) != ssize) { |
|
713 |
+ if((unsigned int) read(desc, src, ssize) != ssize) { |
|
714 | 714 |
cli_dbgmsg("Can't read raw data of section %d\n", i); |
715 | 715 |
free(section_hdr); |
716 | 716 |
free(sections); |
... | ... |
@@ -834,7 +839,7 @@ int cli_scanpe(int desc, const char **virname, long int *scanned, const struct c |
834 | 834 |
return CL_CLEAN; |
835 | 835 |
} |
836 | 836 |
|
837 |
- if(gp >= EC32(section_hdr[i + 1].PointerToRawData) || gp < 0) { |
|
837 |
+ if(gp >= (int) EC32(section_hdr[i + 1].PointerToRawData) || gp < 0) { |
|
838 | 838 |
cli_dbgmsg("FSG: Support data out of padding area (newedi: %d, vaddr: %d)\n", newedi, EC32(section_hdr[i].VirtualAddress)); |
839 | 839 |
break; |
840 | 840 |
} |
... | ... |
@@ -842,7 +847,7 @@ int cli_scanpe(int desc, const char **virname, long int *scanned, const struct c |
842 | 842 |
lseek(desc, gp, SEEK_SET); |
843 | 843 |
gp = EC32(section_hdr[i + 1].PointerToRawData) - gp; |
844 | 844 |
|
845 |
- if(limits && limits->maxfilesize && gp > limits->maxfilesize) { |
|
845 |
+ if(limits && limits->maxfilesize && (unsigned int) gp > limits->maxfilesize) { |
|
846 | 846 |
cli_dbgmsg("FSG: Buffer size exceeded (size: %d, max: %lu)\n", gp, limits->maxfilesize); |
847 | 847 |
free(section_hdr); |
848 | 848 |
return CL_CLEAN; |
... | ... |
@@ -901,7 +906,7 @@ int cli_scanpe(int desc, const char **virname, long int *scanned, const struct c |
901 | 901 |
} |
902 | 902 |
|
903 | 903 |
lseek(desc, EC32(section_hdr[i + 1].PointerToRawData), SEEK_SET); |
904 |
- if(read(desc, src, ssize) != ssize) { |
|
904 |
+ if((unsigned int) read(desc, src, ssize) != ssize) { |
|
905 | 905 |
cli_dbgmsg("Can't read raw data of section %d\n", i); |
906 | 906 |
free(section_hdr); |
907 | 907 |
free(sections); |
... | ... |
@@ -1027,7 +1032,7 @@ int cli_scanpe(int desc, const char **virname, long int *scanned, const struct c |
1027 | 1027 |
} |
1028 | 1028 |
|
1029 | 1029 |
lseek(desc, EC32(section_hdr[i + 1].PointerToRawData), SEEK_SET); |
1030 |
- if(read(desc, src, ssize) != ssize) { |
|
1030 |
+ if((unsigned int) read(desc, src, ssize) != ssize) { |
|
1031 | 1031 |
cli_dbgmsg("Can't read raw data of section %d\n", i); |
1032 | 1032 |
free(section_hdr); |
1033 | 1033 |
free(src); |
... | ... |
@@ -1133,7 +1138,7 @@ int cli_scanpe(int desc, const char **virname, long int *scanned, const struct c |
1133 | 1133 |
return CL_EIO; |
1134 | 1134 |
} |
1135 | 1135 |
|
1136 |
- if(write(ndesc, dest, dsize) != dsize) { |
|
1136 |
+ if((unsigned int) write(ndesc, dest, dsize) != dsize) { |
|
1137 | 1137 |
cli_dbgmsg("UPX/FSG: Can't write %d bytes\n", dsize); |
1138 | 1138 |
free(tempfile); |
1139 | 1139 |
free(dest); |
... | ... |
@@ -1176,8 +1181,8 @@ int cli_scanpe(int desc, const char **virname, long int *scanned, const struct c |
1176 | 1176 |
return CL_EIO; |
1177 | 1177 |
} |
1178 | 1178 |
|
1179 |
- if(buff[0] != '\xb8' || cli_readint32(buff + 1) != EC32(section_hdr[nsections - 1].VirtualAddress) + EC32(optional_hdr.ImageBase)) { |
|
1180 |
- if(nsections < 2 || buff[0] != '\xb8' || cli_readint32(buff + 1) != EC32(section_hdr[nsections - 2].VirtualAddress) + EC32(optional_hdr.ImageBase)) |
|
1179 |
+ if(buff[0] != '\xb8' || (uint32_t) cli_readint32(buff + 1) != EC32(section_hdr[nsections - 1].VirtualAddress) + EC32(optional_hdr.ImageBase)) { |
|
1180 |
+ if(nsections < 2 || buff[0] != '\xb8' || (uint32_t) cli_readint32(buff + 1) != EC32(section_hdr[nsections - 2].VirtualAddress) + EC32(optional_hdr.ImageBase)) |
|
1181 | 1181 |
found = 0; |
1182 | 1182 |
else |
1183 | 1183 |
found = 1; |
... | ... |
@@ -1205,9 +1210,9 @@ int cli_scanpe(int desc, const char **virname, long int *scanned, const struct c |
1205 | 1205 |
|
1206 | 1206 |
for(i = 0 ; i < nsections; i++) { |
1207 | 1207 |
if(section_hdr[i].SizeOfRawData) { |
1208 |
- uint32_t offset = cli_rawaddr(EC32(section_hdr[i].VirtualAddress), section_hdr, nsections); |
|
1208 |
+ uint32_t offset = cli_rawaddr(EC32(section_hdr[i].VirtualAddress), section_hdr, nsections, &err); |
|
1209 | 1209 |
|
1210 |
- if(offset == -1 || lseek(desc, offset, SEEK_SET) == -1 || read(desc, dest + EC32(section_hdr[i].VirtualAddress) - min, EC32(section_hdr[i].SizeOfRawData)) != EC32(section_hdr[i].SizeOfRawData)) { |
|
1210 |
+ if(err || lseek(desc, offset, SEEK_SET) == -1 || (unsigned int) read(desc, dest + EC32(section_hdr[i].VirtualAddress) - min, EC32(section_hdr[i].SizeOfRawData)) != EC32(section_hdr[i].SizeOfRawData)) { |
|
1211 | 1211 |
free(section_hdr); |
1212 | 1212 |
free(dest); |
1213 | 1213 |
return CL_EIO; |
... | ... |
@@ -1285,6 +1290,7 @@ int cli_peheader(int desc, struct cli_pe_info *peinfo) |
1285 | 1285 |
struct pe_image_section_hdr *section_hdr; |
1286 | 1286 |
struct stat sb; |
1287 | 1287 |
int i; |
1288 |
+ unsigned int err; |
|
1288 | 1289 |
|
1289 | 1290 |
|
1290 | 1291 |
cli_dbgmsg("in cli_peheader\n"); |
... | ... |
@@ -1379,7 +1385,9 @@ int cli_peheader(int desc, struct cli_pe_info *peinfo) |
1379 | 1379 |
peinfo->section[i].rsz = EC32(section_hdr[i].SizeOfRawData); |
1380 | 1380 |
} |
1381 | 1381 |
|
1382 |
- if((peinfo->ep = cli_rawaddr(EC32(optional_hdr.AddressOfEntryPoint), section_hdr, peinfo->nsections)) == -1) { |
|
1382 |
+ peinfo->ep = cli_rawaddr(EC32(optional_hdr.AddressOfEntryPoint), section_hdr, peinfo->nsections, &err); |
|
1383 |
+ |
|
1384 |
+ if(err) { |
|
1383 | 1385 |
cli_dbgmsg("Possibly broken PE file\n"); |
1384 | 1386 |
free(section_hdr); |
1385 | 1387 |
free(peinfo->section); |
... | ... |
@@ -100,7 +100,7 @@ struct cli_pe_info { |
100 | 100 |
struct SECTION *section; |
101 | 101 |
}; |
102 | 102 |
|
103 |
-int cli_scanpe(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec); |
|
103 |
+int cli_scanpe(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, unsigned int arec, unsigned int mrec); |
|
104 | 104 |
|
105 | 105 |
int cli_peheader(int desc, struct cli_pe_info *peinfo); |
106 | 106 |
|
... | ... |
@@ -401,7 +401,7 @@ int petite_inflate2x_1to9(char *buf, uint32_t minrva, int bufsz, struct pe_image |
401 | 401 |
backsize--; |
402 | 402 |
} while (backsize); |
403 | 403 |
backbytes^=0xffffffff; |
404 |
- addsize += 1 + ( backbytes < check2 ) + ( backbytes < check1 ); |
|
404 |
+ addsize += 1 + ( backbytes < (int) check2 ) + ( backbytes < (int) check1 ); |
|
405 | 405 |
oldback = backbytes; |
406 | 406 |
} else { |
407 | 407 |
backsize = backbytes+1; |
... | ... |
@@ -478,7 +478,7 @@ int petite_inflate2x_1to9(char *buf, uint32_t minrva, int bufsz, struct pe_image |
478 | 478 |
if (test1 == test2) { |
479 | 479 |
irva = cli_readint32(ddst-grown+0x121-reloc); |
480 | 480 |
enc_ep = cli_readint32(ddst-grown+0x0f-reloc)^test1; |
481 |
- mangled = (cli_readint32(ddst-grown+0x1c0-reloc) != 0x90909090); /* FIXME: Magic's too short??? */ |
|
481 |
+ mangled = ((uint32_t) cli_readint32(ddst-grown+0x1c0-reloc) != 0x90909090); /* FIXME: Magic's too short??? */ |
|
482 | 482 |
cli_dbgmsg("Petite: Encrypted EP: %x | Array of imports: %x\n",enc_ep, irva); |
483 | 483 |
} |
484 | 484 |
usects[j-1].rsz -= grown+reloc; |
... | ... |
@@ -64,7 +64,8 @@ static int cli_ac_addsig(struct cl_node *root, const char *virname, const char * |
64 | 64 |
{ |
65 | 65 |
struct cli_ac_patt *new; |
66 | 66 |
char *pt, *hex; |
67 |
- int virlen, ret, i, error = 0; |
|
67 |
+ int virlen, ret, error = 0; |
|
68 |
+ unsigned int i; |
|
68 | 69 |
|
69 | 70 |
|
70 | 71 |
if((new = (struct cli_ac_patt *) cli_calloc(1, sizeof(struct cli_ac_patt))) == NULL) |
... | ... |
@@ -248,7 +249,8 @@ int cli_parse_add(struct cl_node *root, const char *virname, const char *hexsig, |
248 | 248 |
{ |
249 | 249 |
struct cli_bm_patt *bm_new; |
250 | 250 |
char *pt, *hexcpy, *start, *n; |
251 |
- int ret, virlen, parts = 0, i, j, len, asterisk; |
|
251 |
+ int ret, virlen, asterisk = 0; |
|
252 |
+ unsigned int i, j, len, parts = 0; |
|
252 | 253 |
int mindist = 0, maxdist = 0, error = 0; |
253 | 254 |
|
254 | 255 |
|
... | ... |
@@ -108,7 +108,7 @@ extern int cli_mbox(const char *dir, int desc, unsigned int options); /* FIXME * |
108 | 108 |
|
109 | 109 |
#define MAX_MAIL_RECURSION 15 |
110 | 110 |
|
111 |
-static int cli_scanfile(const char *filename, const char **virname, unsigned long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec); |
|
111 |
+static int cli_scanfile(const char *filename, const char **virname, unsigned long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, unsigned int arec, unsigned int mrec); |
|
112 | 112 |
|
113 | 113 |
|
114 | 114 |
#ifdef CL_THREAD_SAFE |
... | ... |
@@ -119,10 +119,11 @@ static void cli_unlock_mutex(void *mtx) |
119 | 119 |
} |
120 | 120 |
#endif |
121 | 121 |
|
122 |
-static int cli_scanrar(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec) |
|
122 |
+static int cli_scanrar(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, unsigned int arec, unsigned int mrec) |
|
123 | 123 |
{ |
124 | 124 |
FILE *tmp = NULL; |
125 |
- int files = 0, fd, ret = CL_CLEAN, afiles, encrypted; |
|
125 |
+ int fd, ret = CL_CLEAN; |
|
126 |
+ unsigned int files = 0, encrypted, afiles; |
|
126 | 127 |
ArchiveList_struct *rarlist = NULL; |
127 | 128 |
ArchiveList_struct *rarlist_head = NULL; |
128 | 129 |
char *rar_data_ptr; |
... | ... |
@@ -155,7 +156,7 @@ static int cli_scanrar(int desc, const char **virname, long int *scanned, const |
155 | 155 |
files++; |
156 | 156 |
encrypted = rarlist->item.Flags & 0x04; |
157 | 157 |
|
158 |
- cli_dbgmsg("RAR: %s, crc32: 0x%x, encrypted: %d, compressed: %u, normal: %u, method: %d, ratio: %d (max: %d)\n", rarlist->item.Name, rarlist->item.FileCRC, encrypted, rarlist->item.PackSize, rarlist->item.UnpSize, rarlist->item.Method, rarlist->item.PackSize ? (rarlist->item.UnpSize / rarlist->item.PackSize) : 0, limits ? limits->maxratio : -1); |
|
158 |
+ cli_dbgmsg("RAR: %s, crc32: 0x%x, encrypted: %d, compressed: %u, normal: %u, method: %d, ratio: %d (max: %d)\n", rarlist->item.Name, rarlist->item.FileCRC, encrypted, rarlist->item.PackSize, rarlist->item.UnpSize, rarlist->item.Method, rarlist->item.PackSize ? ((unsigned int) rarlist->item.UnpSize / (unsigned int) rarlist->item.PackSize) : 0, limits ? limits->maxratio : 0); |
|
159 | 159 |
|
160 | 160 |
/* Scan metadata */ |
161 | 161 |
mdata = root->rar_mlist; |
... | ... |
@@ -163,22 +164,22 @@ static int cli_scanrar(int desc, const char **virname, long int *scanned, const |
163 | 163 |
if(mdata->encrypted != encrypted) |
164 | 164 |
continue; |
165 | 165 |
|
166 |
- if(mdata->crc32 && mdata->crc32 != rarlist->item.FileCRC) |
|
166 |
+ if(mdata->crc32 && (unsigned int) mdata->crc32 != rarlist->item.FileCRC) |
|
167 | 167 |
continue; |
168 | 168 |
|
169 |
- if(mdata->csize > 0 && mdata->csize != rarlist->item.PackSize) |
|
169 |
+ if(mdata->csize > 0 && (unsigned int) mdata->csize != rarlist->item.PackSize) |
|
170 | 170 |
continue; |
171 | 171 |
|
172 |
- if(mdata->size >= 0 && mdata->size != rarlist->item.UnpSize) |
|
172 |
+ if(mdata->size >= 0 && (unsigned int) mdata->size != rarlist->item.UnpSize) |
|
173 | 173 |
continue; |
174 | 174 |
|
175 |
- if(mdata->method >= 0 && mdata->method != rarlist->item.Method) |
|
175 |
+ if(mdata->method && mdata->method != rarlist->item.Method) |
|
176 | 176 |
continue; |
177 | 177 |
|
178 | 178 |
if(mdata->fileno && mdata->fileno != files) |
179 | 179 |
continue; |
180 | 180 |
|
181 |
- if(mdata->maxdepth && *arec > mdata->maxdepth) |
|
181 |
+ if(mdata->maxdepth && arec > mdata->maxdepth) |
|
182 | 182 |
continue; |
183 | 183 |
|
184 | 184 |
/* TODO add support for regex */ |
... | ... |
@@ -331,14 +332,15 @@ static int cli_scanrar(int desc, const char **virname, long int *scanned, const |
331 | 331 |
} |
332 | 332 |
|
333 | 333 |
#ifdef HAVE_ZLIB_H |
334 |
-static int cli_scanzip(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec) |
|
334 |
+static int cli_scanzip(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, unsigned int arec, unsigned int mrec) |
|
335 | 335 |
{ |
336 | 336 |
ZZIP_DIR *zdir; |
337 | 337 |
ZZIP_DIRENT zdirent; |
338 | 338 |
ZZIP_FILE *zfp; |
339 | 339 |
FILE *tmp = NULL; |
340 | 340 |
char *buff; |
341 |
- int fd, bytes, files = 0, ret = CL_CLEAN, encrypted; |
|
341 |
+ int fd, bytes, ret = CL_CLEAN; |
|
342 |
+ unsigned int files = 0, encrypted; |
|
342 | 343 |
struct stat source; |
343 | 344 |
struct cli_meta_node *mdata; |
344 | 345 |
zzip_error_t err; |
... | ... |
@@ -373,7 +375,7 @@ static int cli_scanzip(int desc, const char **virname, long int *scanned, const |
373 | 373 |
|
374 | 374 |
encrypted = zdirent.d_flags; |
375 | 375 |
|
376 |
- cli_dbgmsg("Zip: %s, crc32: 0x%x, encrypted: %d, compressed: %u, normal: %u, method: %d, ratio: %d (max: %d)\n", zdirent.d_name, zdirent.d_crc32, encrypted, zdirent.d_csize, zdirent.st_size, zdirent.d_compr, zdirent.d_csize ? (zdirent.st_size / zdirent.d_csize) : 0, limits ? limits->maxratio : -1); |
|
376 |
+ cli_dbgmsg("Zip: %s, crc32: 0x%x, encrypted: %d, compressed: %u, normal: %u, method: %d, ratio: %d (max: %d)\n", zdirent.d_name, zdirent.d_crc32, encrypted, zdirent.d_csize, zdirent.st_size, zdirent.d_compr, zdirent.d_csize ? (zdirent.st_size / zdirent.d_csize) : 0, limits ? limits->maxratio : 0); |
|
377 | 377 |
|
378 | 378 |
if(!zdirent.st_size) { |
379 | 379 |
if(zdirent.d_crc32) { |
... | ... |
@@ -391,7 +393,7 @@ static int cli_scanzip(int desc, const char **virname, long int *scanned, const |
391 | 391 |
if(mdata->encrypted != encrypted) |
392 | 392 |
continue; |
393 | 393 |
|
394 |
- if(mdata->crc32 && mdata->crc32 != zdirent.d_crc32) |
|
394 |
+ if(mdata->crc32 && mdata->crc32 != (unsigned int) zdirent.d_crc32) |
|
395 | 395 |
continue; |
396 | 396 |
|
397 | 397 |
if(mdata->csize > 0 && mdata->csize != zdirent.d_csize) |
... | ... |
@@ -400,13 +402,13 @@ static int cli_scanzip(int desc, const char **virname, long int *scanned, const |
400 | 400 |
if(mdata->size >= 0 && mdata->size != zdirent.st_size) |
401 | 401 |
continue; |
402 | 402 |
|
403 |
- if(mdata->method >= 0 && mdata->method != zdirent.d_compr) |
|
403 |
+ if(mdata->method && mdata->method != (unsigned int) zdirent.d_compr) |
|
404 | 404 |
continue; |
405 | 405 |
|
406 | 406 |
if(mdata->fileno && mdata->fileno != files) |
407 | 407 |
continue; |
408 | 408 |
|
409 |
- if(mdata->maxdepth && *arec > mdata->maxdepth) |
|
409 |
+ if(mdata->maxdepth && arec > mdata->maxdepth) |
|
410 | 410 |
continue; |
411 | 411 |
|
412 | 412 |
/* TODO add support for regex */ |
... | ... |
@@ -462,7 +464,7 @@ static int cli_scanzip(int desc, const char **virname, long int *scanned, const |
462 | 462 |
} |
463 | 463 |
|
464 | 464 |
if(limits) { |
465 |
- if(limits->maxfilesize && (zdirent.st_size > limits->maxfilesize)) { |
|
465 |
+ if(limits->maxfilesize && ((unsigned int) zdirent.st_size > limits->maxfilesize)) { |
|
466 | 466 |
cli_dbgmsg("Zip: %s: Size exceeded (%d, max: %ld)\n", zdirent.d_name, zdirent.st_size, limits->maxfilesize); |
467 | 467 |
/* ret = CL_EMAXSIZE; */ |
468 | 468 |
if(BLOCKMAX) { |
... | ... |
@@ -551,10 +553,10 @@ static int cli_scanzip(int desc, const char **virname, long int *scanned, const |
551 | 551 |
return ret; |
552 | 552 |
} |
553 | 553 |
|
554 |
-static int cli_scangzip(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec) |
|
554 |
+static int cli_scangzip(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, unsigned int arec, unsigned int mrec) |
|
555 | 555 |
{ |
556 | 556 |
int fd, bytes, ret = CL_CLEAN; |
557 |
- long int size = 0; |
|
557 |
+ unsigned long int size = 0; |
|
558 | 558 |
char *buff; |
559 | 559 |
FILE *tmp = NULL; |
560 | 560 |
gzFile gd; |
... | ... |
@@ -627,11 +629,11 @@ static int cli_scangzip(int desc, const char **virname, long int *scanned, const |
627 | 627 |
#define BZ2_bzRead bzRead |
628 | 628 |
#endif |
629 | 629 |
|
630 |
-static int cli_scanbzip(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec) |
|
630 |
+static int cli_scanbzip(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, unsigned int arec, unsigned int mrec) |
|
631 | 631 |
{ |
632 | 632 |
int fd, bytes, ret = CL_CLEAN, bzerror = 0; |
633 | 633 |
short memlim = 0; |
634 |
- long int size = 0; |
|
634 |
+ unsigned long int size = 0; |
|
635 | 635 |
char *buff; |
636 | 636 |
FILE *fs, *tmp = NULL; |
637 | 637 |
BZFILE *bfd; |
... | ... |
@@ -708,7 +710,7 @@ static int cli_scanbzip(int desc, const char **virname, long int *scanned, const |
708 | 708 |
} |
709 | 709 |
#endif |
710 | 710 |
|
711 |
-static int cli_scanszdd(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec) |
|
711 |
+static int cli_scanszdd(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, unsigned int arec, unsigned int mrec) |
|
712 | 712 |
{ |
713 | 713 |
int fd, ret = CL_CLEAN; |
714 | 714 |
FILE *tmp = NULL, *in; |
... | ... |
@@ -751,7 +753,7 @@ static int cli_scanszdd(int desc, const char **virname, long int *scanned, const |
751 | 751 |
return ret; |
752 | 752 |
} |
753 | 753 |
|
754 |
-static int cli_scanmscab(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec) |
|
754 |
+static int cli_scanmscab(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, unsigned int arec, unsigned int mrec) |
|
755 | 755 |
{ |
756 | 756 |
struct mscab_decompressor *cabd = NULL; |
757 | 757 |
struct mscabd_cabinet *base, *cab; |
... | ... |
@@ -810,7 +812,7 @@ static int cli_scanmscab(int desc, const char **virname, long int *scanned, cons |
810 | 810 |
return ret; |
811 | 811 |
} |
812 | 812 |
|
813 |
-static int cli_scandir(const char *dirname, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec) |
|
813 |
+static int cli_scandir(const char *dirname, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, unsigned int arec, unsigned int mrec) |
|
814 | 814 |
{ |
815 | 815 |
DIR *dd; |
816 | 816 |
struct dirent *dent; |
... | ... |
@@ -871,7 +873,7 @@ static int cli_scandir(const char *dirname, const char **virname, long int *scan |
871 | 871 |
return 0; |
872 | 872 |
} |
873 | 873 |
|
874 |
-static int cli_vba_scandir(const char *dirname, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec) |
|
874 |
+static int cli_vba_scandir(const char *dirname, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, unsigned int arec, unsigned int mrec) |
|
875 | 875 |
{ |
876 | 876 |
int ret = CL_CLEAN, i, fd, data_len; |
877 | 877 |
vba_project_t *vba_project; |
... | ... |
@@ -1016,7 +1018,7 @@ static int cli_vba_scandir(const char *dirname, const char **virname, long int * |
1016 | 1016 |
return ret; |
1017 | 1017 |
} |
1018 | 1018 |
|
1019 |
-static int cli_scanhtml(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec) |
|
1019 |
+static int cli_scanhtml(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, unsigned int arec, unsigned int mrec) |
|
1020 | 1020 |
{ |
1021 | 1021 |
char *tempname, fullname[1024]; |
1022 | 1022 |
int ret=CL_CLEAN, fd; |
... | ... |
@@ -1089,7 +1091,7 @@ static int cli_scanhtml(int desc, const char **virname, long int *scanned, const |
1089 | 1089 |
return ret; |
1090 | 1090 |
} |
1091 | 1091 |
|
1092 |
-static int cli_scanole2(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec) |
|
1092 |
+static int cli_scanole2(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, unsigned int arec, unsigned int mrec) |
|
1093 | 1093 |
{ |
1094 | 1094 |
char *dir; |
1095 | 1095 |
int ret = CL_CLEAN; |
... | ... |
@@ -1124,7 +1126,7 @@ static int cli_scanole2(int desc, const char **virname, long int *scanned, const |
1124 | 1124 |
return ret; |
1125 | 1125 |
} |
1126 | 1126 |
|
1127 |
-static int cli_scantar(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec) |
|
1127 |
+static int cli_scantar(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, unsigned int arec, unsigned int mrec) |
|
1128 | 1128 |
{ |
1129 | 1129 |
char *dir; |
1130 | 1130 |
int ret = CL_CLEAN; |
... | ... |
@@ -1151,7 +1153,7 @@ static int cli_scantar(int desc, const char **virname, long int *scanned, const |
1151 | 1151 |
return ret; |
1152 | 1152 |
} |
1153 | 1153 |
|
1154 |
-static int cli_scanbinhex(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec) |
|
1154 |
+static int cli_scanbinhex(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, unsigned int arec, unsigned int mrec) |
|
1155 | 1155 |
{ |
1156 | 1156 |
char *dir; |
1157 | 1157 |
int ret = CL_CLEAN; |
... | ... |
@@ -1179,7 +1181,7 @@ static int cli_scanbinhex(int desc, const char **virname, long int *scanned, con |
1179 | 1179 |
return ret; |
1180 | 1180 |
} |
1181 | 1181 |
|
1182 |
-static int cli_scanmschm(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec) |
|
1182 |
+static int cli_scanmschm(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, unsigned int arec, unsigned int mrec) |
|
1183 | 1183 |
{ |
1184 | 1184 |
char *tempname; |
1185 | 1185 |
int ret = CL_CLEAN; |
... | ... |
@@ -1203,7 +1205,7 @@ static int cli_scanmschm(int desc, const char **virname, long int *scanned, cons |
1203 | 1203 |
return ret; |
1204 | 1204 |
} |
1205 | 1205 |
|
1206 |
-static int cli_scanscrenc(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec) |
|
1206 |
+static int cli_scanscrenc(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, unsigned int arec, unsigned int mrec) |
|
1207 | 1207 |
{ |
1208 | 1208 |
char *tempname; |
1209 | 1209 |
int ret = CL_CLEAN; |
... | ... |
@@ -1226,7 +1228,7 @@ static int cli_scanscrenc(int desc, const char **virname, long int *scanned, con |
1226 | 1226 |
return ret; |
1227 | 1227 |
} |
1228 | 1228 |
|
1229 |
-static int cli_scanriff(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec) |
|
1229 |
+static int cli_scanriff(int desc, const char **virname) |
|
1230 | 1230 |
{ |
1231 | 1231 |
int ret = CL_CLEAN; |
1232 | 1232 |
|
... | ... |
@@ -1238,13 +1240,13 @@ static int cli_scanriff(int desc, const char **virname, long int *scanned, const |
1238 | 1238 |
return ret; |
1239 | 1239 |
} |
1240 | 1240 |
|
1241 |
-static int cli_scanmail(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec) |
|
1241 |
+static int cli_scanmail(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, unsigned int arec, unsigned int mrec) |
|
1242 | 1242 |
{ |
1243 | 1243 |
char *dir; |
1244 | 1244 |
int ret; |
1245 | 1245 |
|
1246 | 1246 |
|
1247 |
- cli_dbgmsg("Starting cli_scanmail(), mrec == %d, arec == %d\n", *mrec, *arec); |
|
1247 |
+ cli_dbgmsg("Starting cli_scanmail(), mrec == %d, arec == %d\n", mrec, arec); |
|
1248 | 1248 |
|
1249 | 1249 |
/* generate the temporary directory */ |
1250 | 1250 |
dir = cli_gentemp(NULL); |
... | ... |
@@ -1273,7 +1275,7 @@ static int cli_scanmail(int desc, const char **virname, long int *scanned, const |
1273 | 1273 |
return ret; |
1274 | 1274 |
} |
1275 | 1275 |
|
1276 |
-int cli_magic_scandesc(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec) |
|
1276 |
+int cli_magic_scandesc(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, unsigned int arec, unsigned int mrec) |
|
1277 | 1277 |
{ |
1278 | 1278 |
char magic[MAGIC_BUFFER_SIZE + 1]; |
1279 | 1279 |
int ret = CL_CLEAN, nret; |
... | ... |
@@ -1294,8 +1296,8 @@ int cli_magic_scandesc(int desc, const char **virname, long int *scanned, const |
1294 | 1294 |
} |
1295 | 1295 |
|
1296 | 1296 |
if(SCAN_ARCHIVE && limits && limits->maxreclevel) |
1297 |
- if(*arec > limits->maxreclevel) { |
|
1298 |
- cli_dbgmsg("Archive recursion limit exceeded (arec == %d).\n", *arec); |
|
1297 |
+ if(arec > limits->maxreclevel) { |
|
1298 |
+ cli_dbgmsg("Archive recursion limit exceeded (arec == %d).\n", arec); |
|
1299 | 1299 |
if(BLOCKMAX) { |
1300 | 1300 |
*virname = "Archive.ExceededRecursionLimit"; |
1301 | 1301 |
return CL_VIRUS; |
... | ... |
@@ -1304,8 +1306,8 @@ int cli_magic_scandesc(int desc, const char **virname, long int *scanned, const |
1304 | 1304 |
} |
1305 | 1305 |
|
1306 | 1306 |
if(SCAN_MAIL) |
1307 |
- if(*mrec > MAX_MAIL_RECURSION) { |
|
1308 |
- cli_dbgmsg("Mail recursion level exceeded (mrec == %d).\n", *mrec); |
|
1307 |
+ if(mrec > MAX_MAIL_RECURSION) { |
|
1308 |
+ cli_dbgmsg("Mail recursion level exceeded (mrec == %d).\n", mrec); |
|
1309 | 1309 |
/* return CL_EMAXREC; */ |
1310 | 1310 |
return CL_CLEAN; |
1311 | 1311 |
} |
... | ... |
@@ -1324,7 +1326,7 @@ int cli_magic_scandesc(int desc, const char **virname, long int *scanned, const |
1324 | 1324 |
lseek(desc, 0, SEEK_SET); |
1325 | 1325 |
type = cli_filetype(magic, bread); |
1326 | 1326 |
|
1327 |
- type == CL_TYPE_MAIL ? (*mrec)++ : (*arec)++; |
|
1327 |
+ type == CL_TYPE_MAIL ? mrec++ : arec++; |
|
1328 | 1328 |
|
1329 | 1329 |
switch(type) { |
1330 | 1330 |
case CL_TYPE_RAR: |
... | ... |
@@ -1389,7 +1391,7 @@ int cli_magic_scandesc(int desc, const char **virname, long int *scanned, const |
1389 | 1389 |
break; |
1390 | 1390 |
|
1391 | 1391 |
case CL_TYPE_RIFF: |
1392 |
- ret = cli_scanriff(desc, virname, scanned, root, limits, options, arec, mrec); |
|
1392 |
+ ret = cli_scanriff(desc, virname); |
|
1393 | 1393 |
break; |
1394 | 1394 |
|
1395 | 1395 |
case CL_TYPE_DATA: |
... | ... |
@@ -1408,7 +1410,7 @@ int cli_magic_scandesc(int desc, const char **virname, long int *scanned, const |
1408 | 1408 |
break; |
1409 | 1409 |
} |
1410 | 1410 |
|
1411 |
- type == CL_TYPE_MAIL ? (*mrec)-- : (*arec)--; |
|
1411 |
+ type == CL_TYPE_MAIL ? mrec-- : arec--; |
|
1412 | 1412 |
|
1413 | 1413 |
if(type != CL_TYPE_DATA && ret != CL_VIRUS) { /* scan the raw file */ |
1414 | 1414 |
int typerec; |
... | ... |
@@ -1427,7 +1429,7 @@ int cli_magic_scandesc(int desc, const char **virname, long int *scanned, const |
1427 | 1427 |
} else if(nret >= CL_TYPENO) { |
1428 | 1428 |
lseek(desc, 0, SEEK_SET); |
1429 | 1429 |
|
1430 |
- nret == CL_TYPE_MAIL ? (*mrec)++ : (*arec)++; |
|
1430 |
+ nret == CL_TYPE_MAIL ? mrec++ : arec++; |
|
1431 | 1431 |
switch(nret) { |
1432 | 1432 |
case CL_TYPE_HTML: |
1433 | 1433 |
if(SCAN_HTML) |
... | ... |
@@ -1441,11 +1443,11 @@ int cli_magic_scandesc(int desc, const char **virname, long int *scanned, const |
1441 | 1441 |
return CL_VIRUS; |
1442 | 1442 |
break; |
1443 | 1443 |
} |
1444 |
- nret == CL_TYPE_MAIL ? (*mrec)-- : (*arec)--; |
|
1444 |
+ nret == CL_TYPE_MAIL ? mrec-- : arec--; |
|
1445 | 1445 |
} |
1446 | 1446 |
} |
1447 | 1447 |
|
1448 |
- (*arec)++; |
|
1448 |
+ arec++; |
|
1449 | 1449 |
lseek(desc, 0, SEEK_SET); |
1450 | 1450 |
switch(type) { |
1451 | 1451 |
/* Due to performance reasons all executables were first scanned |
... | ... |
@@ -1459,7 +1461,7 @@ int cli_magic_scandesc(int desc, const char **virname, long int *scanned, const |
1459 | 1459 |
default: |
1460 | 1460 |
break; |
1461 | 1461 |
} |
1462 |
- (*arec)--; |
|
1462 |
+ arec--; |
|
1463 | 1463 |
|
1464 | 1464 |
if(ret == CL_EFORMAT) { |
1465 | 1465 |
cli_dbgmsg("Descriptor[%d]: %s\n", desc, cl_strerror(CL_EFORMAT)); |
... | ... |
@@ -1471,12 +1473,10 @@ int cli_magic_scandesc(int desc, const char **virname, long int *scanned, const |
1471 | 1471 |
|
1472 | 1472 |
int cl_scandesc(int desc, const char **virname, unsigned long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options) |
1473 | 1473 |
{ |
1474 |
- int arec = 0, mrec = 0; |
|
1475 |
- |
|
1476 |
- return cli_magic_scandesc(desc, virname, scanned, root, limits, options, &arec, &mrec); |
|
1474 |
+ return cli_magic_scandesc(desc, virname, scanned, root, limits, options, 0, 0); |
|
1477 | 1475 |
} |
1478 | 1476 |
|
1479 |
-static int cli_scanfile(const char *filename, const char **virname, unsigned long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec) |
|
1477 |
+static int cli_scanfile(const char *filename, const char **virname, unsigned long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, unsigned int arec, unsigned int mrec) |
|
1480 | 1478 |
{ |
1481 | 1479 |
int fd, ret; |
1482 | 1480 |
|
... | ... |
@@ -21,6 +21,6 @@ |
21 | 21 |
|
22 | 22 |
#include "clamav.h" |
23 | 23 |
|
24 |
-int cli_magic_scandesc(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, int *arec, int *mrec); |
|
24 |
+int cli_magic_scandesc(int desc, const char **virname, long int *scanned, const struct cl_node *root, const struct cl_limits *limits, unsigned int options, unsigned int arec, unsigned int mrec); |
|
25 | 25 |
|
26 | 26 |
#endif |