git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@1404 77e5149b-7576-45b1-b177-96237e5ba77b
Trog authored on 2005/03/18 22:52:06... | ... |
@@ -1,3 +1,11 @@ |
1 |
+Fri Mar 18 13:48:40 GMT 2005 (trog) |
|
2 |
+----------------------------------- |
|
3 |
+ * clamd/scanner.c: fix ports scan loop |
|
4 |
+ |
|
5 |
+ * clamd/server-th.c, libclamav/vba_extract.c, libclamav/special.c, |
|
6 |
+ libclamav/chmunpack.c, libclamav/ole2_extract.c: |
|
7 |
+ Fix compiler warnings. |
|
8 |
+ |
|
1 | 9 |
Fri Mar 18 12:46:49 CET 2005 (tk) |
2 | 10 |
--------------------------------- |
3 | 11 |
* update copyright information |
... | ... |
@@ -325,7 +325,7 @@ int scanstream(int odesc, unsigned long int *scanned, const struct cl_node *root |
325 | 325 |
max_port = 2048; |
326 | 326 |
|
327 | 327 |
/* bind to a free port */ |
328 |
- while(!bound && portscan--) { |
|
328 |
+ while(!bound && --portscan) { |
|
329 | 329 |
if(rnd_port_first) { |
330 | 330 |
/* try a random port first */ |
331 | 331 |
port = min_port + cli_rndnum(max_port - min_port + 1); |
... | ... |
@@ -543,7 +543,7 @@ int acceptloop_th(int socketd, struct cl_node *root, const struct cfgstruct *cop |
543 | 543 |
|
544 | 544 |
if(selfchk) { |
545 | 545 |
time(¤t_time); |
546 |
- if((current_time - start_time) > selfchk) { |
|
546 |
+ if((current_time - start_time) > (time_t)selfchk) { |
|
547 | 547 |
if(reload_db(root, copt, TRUE)) { |
548 | 548 |
pthread_mutex_lock(&reload_mutex); |
549 | 549 |
reload = 1; |
... | ... |
@@ -184,7 +184,7 @@ static uint64_t chm_endian_convert_64(uint64_t v) |
184 | 184 |
#endif |
185 | 185 |
|
186 | 186 |
/* Read in a block of data from either the mmap area or the given fd */ |
187 |
-int chm_read_data(int fd, unsigned char *dest, off_t offset, uint32_t len, |
|
187 |
+int chm_read_data(int fd, unsigned char *dest, off_t offset, off_t len, |
|
188 | 188 |
unsigned char *m_area, off_t m_length) |
189 | 189 |
{ |
190 | 190 |
if (m_area != NULL) { |
... | ... |
@@ -203,7 +203,7 @@ int chm_read_data(int fd, unsigned char *dest, off_t offset, uint32_t len, |
203 | 203 |
return TRUE; |
204 | 204 |
} |
205 | 205 |
|
206 |
-int chm_copy_file_data(int ifd, int ofd, uint64_t len) |
|
206 |
+uint64_t chm_copy_file_data(int ifd, int ofd, uint64_t len) |
|
207 | 207 |
{ |
208 | 208 |
unsigned char data[8192]; |
209 | 209 |
uint64_t count, rem; |
... | ... |
@@ -217,7 +217,7 @@ int chm_copy_file_data(int ifd, int ofd, uint64_t len) |
217 | 217 |
if (count != todo) { |
218 | 218 |
return len-rem; |
219 | 219 |
} |
220 |
- if (cli_writen(ofd, data, count) != count) { |
|
220 |
+ if (cli_writen(ofd, data, count) != (int64_t)count) { |
|
221 | 221 |
return len-rem-count; |
222 | 222 |
} |
223 | 223 |
rem -= count; |
... | ... |
@@ -437,12 +437,12 @@ static uint64_t read_enc_int(unsigned char **start, unsigned char *end) |
437 | 437 |
current = *start; |
438 | 438 |
|
439 | 439 |
if (current > end) { |
440 |
- return -1; |
|
440 |
+ return 0; |
|
441 | 441 |
} |
442 | 442 |
|
443 | 443 |
do { |
444 | 444 |
if (current > end) { |
445 |
- return -1; |
|
445 |
+ return 0; |
|
446 | 446 |
} |
447 | 447 |
retval = (retval << 7) | (*current & 0x7f); |
448 | 448 |
} while (*current++ & 0x80); |
... | ... |
@@ -476,7 +476,7 @@ static int read_chunk_entries(unsigned char *chunk, uint32_t chunk_len, |
476 | 476 |
} |
477 | 477 |
file_e->next = NULL; |
478 | 478 |
|
479 |
- if ((name_len = read_enc_int(¤t, end)) < 0) return FALSE; |
|
479 |
+ name_len = read_enc_int(¤t, end); |
|
480 | 480 |
file_e->name = (unsigned char *) cli_malloc(name_len+1); |
481 | 481 |
if (!file_e->name) { |
482 | 482 |
free(file_e); |
... | ... |
@@ -485,21 +485,9 @@ static int read_chunk_entries(unsigned char *chunk, uint32_t chunk_len, |
485 | 485 |
strncpy(file_e->name, current, name_len); |
486 | 486 |
file_e->name[name_len] = '\0'; |
487 | 487 |
current += name_len; |
488 |
- if ((file_e->section = read_enc_int(¤t, end)) < 0) { |
|
489 |
- free(file_e->name); |
|
490 |
- free(file_e); |
|
491 |
- return FALSE; |
|
492 |
- } |
|
493 |
- if ((file_e->offset = read_enc_int(¤t, end)) < 0) { |
|
494 |
- free(file_e->name); |
|
495 |
- free(file_e); |
|
496 |
- return FALSE; |
|
497 |
- } |
|
498 |
- if ((file_e->length = read_enc_int(¤t, end)) < 0) { |
|
499 |
- free(file_e->name); |
|
500 |
- free(file_e); |
|
501 |
- return FALSE; |
|
502 |
- } |
|
488 |
+ file_e->section = read_enc_int(¤t, end); |
|
489 |
+ file_e->offset = read_enc_int(¤t, end); |
|
490 |
+ file_e->length = read_enc_int(¤t, end); |
|
503 | 491 |
if ((name_len >= 2) && (file_e->name[0] == ':') && |
504 | 492 |
(file_e->name[1] == ':')) { |
505 | 493 |
file_e->next = sys_file_l->next; |
... | ... |
@@ -969,7 +957,7 @@ static int chm_decompress_stream(int fd, const char *dirname, itsf_header_t *its |
969 | 969 |
entry = entry->next; |
970 | 970 |
continue; |
971 | 971 |
} |
972 |
- if (lseek(mf_out.desc, entry->offset, SEEK_SET) != entry->offset) { |
|
972 |
+ if (lseek(mf_out.desc, entry->offset, SEEK_SET) != (off_t)entry->offset) { |
|
973 | 973 |
cli_dbgmsg("seek in output failed\n"); |
974 | 974 |
entry = entry->next; |
975 | 975 |
continue; |
... | ... |
@@ -981,8 +969,8 @@ static int chm_decompress_stream(int fd, const char *dirname, itsf_header_t *its |
981 | 981 |
entry = entry->next; |
982 | 982 |
continue; |
983 | 983 |
} |
984 |
- if ((length=chm_copy_file_data(mf_out.desc, ofd, entry->length)) != entry->length) { |
|
985 |
- cli_dbgmsg("copied %d of %d\n", length, entry->length); |
|
984 |
+ if (chm_copy_file_data(mf_out.desc, ofd, entry->length) != entry->length) { |
|
985 |
+ cli_dbgmsg("failed to copy %lu bytes\n", entry->length); |
|
986 | 986 |
} |
987 | 987 |
|
988 | 988 |
close(ofd); |
... | ... |
@@ -633,7 +633,7 @@ static int handler_writefile(int fd, ole2_header_t *hdr, property_t *prop, const |
633 | 633 |
} |
634 | 634 |
|
635 | 635 |
while((current_block >= 0) && (len > 0)) { |
636 |
- if (prop->size < hdr->sbat_cutoff) { |
|
636 |
+ if (prop->size < (int64_t)hdr->sbat_cutoff) { |
|
637 | 637 |
/* Small block file */ |
638 | 638 |
if (!ole2_get_sbat_data_block(fd, hdr, buff, current_block)) { |
639 | 639 |
cli_dbgmsg("ole2_get_sbat_data_block failed\n"); |
... | ... |
@@ -757,7 +757,7 @@ static int ppt_unlzw(const char *dir, int fd, uint32_t length) |
757 | 757 |
stream.next_in = inbuff; |
758 | 758 |
bufflen = stream.avail_in = MIN(length, PPT_LZW_BUFFSIZE); |
759 | 759 |
|
760 |
- if (cli_readn(fd, inbuff, stream.avail_in) != stream.avail_in) { |
|
760 |
+ if (cli_readn(fd, inbuff, stream.avail_in) != (int64_t)stream.avail_in) { |
|
761 | 761 |
close(ofd); |
762 | 762 |
return FALSE; |
763 | 763 |
} |
... | ... |
@@ -785,7 +785,7 @@ static int ppt_unlzw(const char *dir, int fd, uint32_t length) |
785 | 785 |
if (stream.avail_in == 0) { |
786 | 786 |
stream.next_in = inbuff; |
787 | 787 |
bufflen = stream.avail_in = MIN(length, PPT_LZW_BUFFSIZE); |
788 |
- if (cli_readn(fd, inbuff, stream.avail_in) != stream.avail_in) { |
|
788 |
+ if (cli_readn(fd, inbuff, stream.avail_in) != (int64_t)stream.avail_in) { |
|
789 | 789 |
close(ofd); |
790 | 790 |
inflateEnd(&stream); |
791 | 791 |
return FALSE; |
... | ... |
@@ -795,7 +795,7 @@ static int ppt_unlzw(const char *dir, int fd, uint32_t length) |
795 | 795 |
retval = inflate(&stream, Z_NO_FLUSH); |
796 | 796 |
} while (retval == Z_OK); |
797 | 797 |
|
798 |
- if (cli_writen(ofd, outbuff, bufflen) != bufflen) { |
|
798 |
+ if (cli_writen(ofd, outbuff, bufflen) != (int64_t)bufflen) { |
|
799 | 799 |
close(ofd); |
800 | 800 |
inflateEnd(&stream); |
801 | 801 |
return FALSE; |
... | ... |
@@ -853,7 +853,7 @@ static char *ppt_stream_iter(int fd) |
853 | 853 |
} else { |
854 | 854 |
offset = lseek(fd, 0, SEEK_CUR); |
855 | 855 |
/* Check we don't wrap */ |
856 |
- if ((offset + atom_header.length) < offset) { |
|
856 |
+ if ((offset + (off_t)atom_header.length) < offset) { |
|
857 | 857 |
break; |
858 | 858 |
} |
859 | 859 |
offset += atom_header.length; |
... | ... |
@@ -1470,7 +1470,7 @@ vba_project_t *wm_dir_read(const char *dir) |
1470 | 1470 |
} |
1471 | 1471 |
wm_print_fib(&fib); |
1472 | 1472 |
|
1473 |
- if (lseek(fd, fib.macro_offset, SEEK_SET) != fib.macro_offset) { |
|
1473 |
+ if (lseek(fd, fib.macro_offset, SEEK_SET) != (int64_t)fib.macro_offset) { |
|
1474 | 1474 |
cli_dbgmsg("lseek macro_offset failed\n"); |
1475 | 1475 |
close(fd); |
1476 | 1476 |
return NULL; |
... | ... |
@@ -1611,7 +1611,7 @@ unsigned char *wm_decrypt_macro(int fd, uint32_t offset, uint32_t len, |
1611 | 1611 |
unsigned char *buff; |
1612 | 1612 |
uint32_t i; |
1613 | 1613 |
|
1614 |
- if (lseek(fd, offset, SEEK_SET) != offset) { |
|
1614 |
+ if (lseek(fd, offset, SEEK_SET) != (int64_t)offset) { |
|
1615 | 1615 |
return NULL; |
1616 | 1616 |
} |
1617 | 1617 |
buff = (unsigned char *) cli_malloc(len); |
... | ... |
@@ -1619,7 +1619,7 @@ unsigned char *wm_decrypt_macro(int fd, uint32_t offset, uint32_t len, |
1619 | 1619 |
return NULL; |
1620 | 1620 |
} |
1621 | 1621 |
|
1622 |
- if (cli_readn(fd, buff, len) != len) { |
|
1622 |
+ if (cli_readn(fd, buff, len) != (int64_t)len) { |
|
1623 | 1623 |
free(buff); |
1624 | 1624 |
return NULL; |
1625 | 1625 |
} |