git-svn: trunk@3582
Tomasz Kojm authored on 2008/02/05 02:39:00... | ... |
@@ -171,12 +171,12 @@ static void itsf_print_header(chm_itsf_header_t *itsf_hdr) |
171 | 171 |
cli_dbgmsg("Version:\t%d\n", itsf_hdr->version); |
172 | 172 |
cli_dbgmsg("Header len:\t%d\n", itsf_hdr->header_len); |
173 | 173 |
cli_dbgmsg("Lang ID:\t%d\n", itsf_hdr->lang_id); |
174 |
- cli_dbgmsg("Sec0 offset:\t%llu\n", itsf_hdr->sec0_offset); |
|
175 |
- cli_dbgmsg("Sec0 len:\t%llu\n", itsf_hdr->sec0_len); |
|
176 |
- cli_dbgmsg("Dir offset:\t%llu\n", itsf_hdr->dir_offset); |
|
177 |
- cli_dbgmsg("Dir len:\t%llu\n", itsf_hdr->dir_len); |
|
174 |
+ cli_dbgmsg("Sec0 offset:\t%lu\n", (unsigned long int) itsf_hdr->sec0_offset); |
|
175 |
+ cli_dbgmsg("Sec0 len:\t%lu\n", (unsigned long int) itsf_hdr->sec0_len); |
|
176 |
+ cli_dbgmsg("Dir offset:\t%lu\n", (unsigned long int) itsf_hdr->dir_offset); |
|
177 |
+ cli_dbgmsg("Dir len:\t%lu\n", (unsigned long int) itsf_hdr->dir_len); |
|
178 | 178 |
if (itsf_hdr->version > 2) { |
179 |
- cli_dbgmsg("Data offset:\t%llu\n\n", itsf_hdr->data_offset); |
|
179 |
+ cli_dbgmsg("Data offset:\t%lu\n\n", (unsigned long int) itsf_hdr->data_offset); |
|
180 | 180 |
} |
181 | 181 |
} |
182 | 182 |
|
... | ... |
@@ -470,7 +470,7 @@ static int read_chunk(chm_metadata_t *metadata, int fd) |
470 | 470 |
if (lseek(fd, metadata->chunk_offset, SEEK_SET) != metadata->chunk_offset) { |
471 | 471 |
goto abort; |
472 | 472 |
} |
473 |
- if (cli_readn(fd, metadata->chunk_data, metadata->itsp_hdr.block_len) != metadata->itsp_hdr.block_len) { |
|
473 |
+ if ((uint32_t) cli_readn(fd, metadata->chunk_data, metadata->itsp_hdr.block_len) != metadata->itsp_hdr.block_len) { |
|
474 | 474 |
goto abort; |
475 | 475 |
} |
476 | 476 |
} |
... | ... |
@@ -585,8 +585,8 @@ static void print_sys_content(lzx_content_t *lzx_content) |
585 | 585 |
} |
586 | 586 |
|
587 | 587 |
cli_dbgmsg("---- Content ----\n"); |
588 |
- cli_dbgmsg("Offset:\t%llu\n", lzx_content->offset); |
|
589 |
- cli_dbgmsg("Length:\t%llu\n\n", lzx_content->length); |
|
588 |
+ cli_dbgmsg("Offset:\t%lu\n", (unsigned long int) lzx_content->offset); |
|
589 |
+ cli_dbgmsg("Length:\t%lu\n\n", (unsigned long int) lzx_content->length); |
|
590 | 590 |
} |
591 | 591 |
|
592 | 592 |
static int read_sys_content(int fd, chm_metadata_t *metadata, lzx_content_t *lzx_content) |
... | ... |
@@ -608,9 +608,9 @@ static void print_sys_reset_table(lzx_reset_table_t *lzx_reset_table) |
608 | 608 |
cli_dbgmsg("Num Entries:\t%u\n", lzx_reset_table->num_entries); |
609 | 609 |
cli_dbgmsg("Entry Size:\t%u\n", lzx_reset_table->entry_size); |
610 | 610 |
cli_dbgmsg("Table Offset:\t%u\n", lzx_reset_table->table_offset); |
611 |
- cli_dbgmsg("Uncom Len:\t%llu\n", lzx_reset_table->uncom_len); |
|
612 |
- cli_dbgmsg("Com Len:\t%llu\n", lzx_reset_table->com_len); |
|
613 |
- cli_dbgmsg("Frame Len:\t%llu\n\n", lzx_reset_table->frame_len); |
|
611 |
+ cli_dbgmsg("Uncom Len:\t%lu\n", (unsigned long int) lzx_reset_table->uncom_len); |
|
612 |
+ cli_dbgmsg("Com Len:\t%lu\n", (unsigned long int) lzx_reset_table->com_len); |
|
613 |
+ cli_dbgmsg("Frame Len:\t%lu\n\n", (unsigned long int) lzx_reset_table->frame_len); |
|
614 | 614 |
} |
615 | 615 |
|
616 | 616 |
static int read_sys_reset_table(int fd, chm_metadata_t *metadata, lzx_reset_table_t *lzx_reset_table) |
... | ... |
@@ -748,8 +748,8 @@ static int chm_decompress_stream(int fd, chm_metadata_t *metadata, const char *d |
748 | 748 |
length += lzx_control.reset_interval; |
749 | 749 |
length &= -lzx_control.reset_interval; |
750 | 750 |
|
751 |
- cli_dbgmsg("Compressed offset: %llu\n", lzx_content.offset); |
|
752 |
- if (lseek(fd, lzx_content.offset, SEEK_SET) != lzx_content.offset) { |
|
751 |
+ cli_dbgmsg("Compressed offset: %lu\n", (unsigned long int) lzx_content.offset); |
|
752 |
+ if ((uint64_t) lseek(fd, lzx_content.offset, SEEK_SET) != lzx_content.offset) { |
|
753 | 753 |
goto abort; |
754 | 754 |
} |
755 | 755 |
|
... | ... |
@@ -816,7 +816,7 @@ int cli_chm_extract_file(int fd, char *dirname, chm_metadata_t *metadata) |
816 | 816 |
cli_dbgmsg("seek in uncompressed stream failed\n"); |
817 | 817 |
return CL_EFORMAT; |
818 | 818 |
} |
819 |
- snprintf(filename, 1024, "%s/%llu.chm", dirname, metadata->file_offset); |
|
819 |
+ snprintf(filename, 1024, "%s/%lu.chm", dirname, (unsigned long int) metadata->file_offset); |
|
820 | 820 |
metadata->ofd = open(filename, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IRWXU); |
821 | 821 |
if (metadata->ofd < 0) { |
822 | 822 |
return CL_EIO; |
... | ... |
@@ -112,6 +112,9 @@ typedef struct chm_metadata_tag { |
112 | 112 |
uint16_t chunk_entries; |
113 | 113 |
} chm_metadata_t; |
114 | 114 |
|
115 |
-int chm_unpack(int fd, const char *dirname); |
|
115 |
+int cli_chm_open(int fd, const char *dirname, chm_metadata_t *metadata); |
|
116 |
+int cli_chm_prepare_file(int fd, char *dirname, chm_metadata_t *metadata); |
|
117 |
+int cli_chm_extract_file(int fd, char *dirname, chm_metadata_t *metadata); |
|
118 |
+void cli_chm_close(chm_metadata_t *metadata); |
|
116 | 119 |
|
117 | 120 |
#endif |
... | ... |
@@ -100,7 +100,7 @@ static char const rcsid[] = "$Id: mbox.c,v 1.381 2007/02/15 12:26:44 njh Exp $"; |
100 | 100 |
static void sigsegv(int sig); |
101 | 101 |
static void print_trace(int use_syslog); |
102 | 102 |
|
103 |
-/*#define SAVE_TMP /* Save the file being worked on in tmp */ |
|
103 |
+/*#define SAVE_TMP */ /* Save the file being worked on in tmp */ |
|
104 | 104 |
#endif |
105 | 105 |
|
106 | 106 |
#if defined(NO_STRTOK_R) || !defined(CL_THREAD_SAFE) |
... | ... |
@@ -1414,6 +1414,9 @@ cli_parse_mbox(const char *dir, int desc, cli_ctx *ctx) |
1414 | 1414 |
if((retcode == CL_SUCCESS) && messageGetBody(body)) { |
1415 | 1415 |
messageSetCTX(body, ctx); |
1416 | 1416 |
switch(parseEmailBody(body, NULL, &mctx, 0)) { |
1417 |
+ case OK: |
|
1418 |
+ case OK_ATTACHMENTS_NOT_SAVED: |
|
1419 |
+ break; |
|
1417 | 1420 |
case FAIL: |
1418 | 1421 |
/* |
1419 | 1422 |
* beware: cli_magic_scandesc(), |
... | ... |
@@ -3044,7 +3047,7 @@ parseEmailBody(message *messageIn, text *textIn, mbox_ctx *mctx, unsigned int re |
3044 | 3044 |
} |
3045 | 3045 |
} |
3046 | 3046 |
} /*else |
3047 |
- rc = OK_ATTACHMENTS_NOT_SAVED; /* nothing saved */ |
|
3047 |
+ rc = OK_ATTACHMENTS_NOT_SAVED; */ /* nothing saved */ |
|
3048 | 3048 |
|
3049 | 3049 |
if(mainMessage && (mainMessage != messageIn)) |
3050 | 3050 |
messageDestroy(mainMessage); |
... | ... |
@@ -49,7 +49,7 @@ |
49 | 49 |
*/ |
50 | 50 |
#if defined(__i386__) || defined(__x86_64__) || defined(__vax__) |
51 | 51 |
#define SET(n) \ |
52 |
- (*(MD5_u32plus *)&ptr[(n) * 4]) |
|
52 |
+ (*(const MD5_u32plus *)&ptr[(n) * 4]) |
|
53 | 53 |
#define GET(n) \ |
54 | 54 |
SET(n) |
55 | 55 |
#else |
... | ... |
@@ -67,9 +67,9 @@ |
67 | 67 |
* This processes one or more 64-byte data blocks, but does NOT update |
68 | 68 |
* the bit counters. There are no alignment requirements. |
69 | 69 |
*/ |
70 |
-static void *body(cli_md5_ctx *ctx, void *data, unsigned long size) |
|
70 |
+static const void *body(cli_md5_ctx *ctx, const void *data, unsigned long size) |
|
71 | 71 |
{ |
72 |
- unsigned char *ptr; |
|
72 |
+ const unsigned char *ptr; |
|
73 | 73 |
MD5_u32plus a, b, c, d; |
74 | 74 |
MD5_u32plus saved_a, saved_b, saved_c, saved_d; |
75 | 75 |
|
... | ... |
@@ -185,7 +185,7 @@ void cli_md5_init(cli_md5_ctx *ctx) |
185 | 185 |
ctx->hi = 0; |
186 | 186 |
} |
187 | 187 |
|
188 |
-void cli_md5_update(cli_md5_ctx *ctx, void *data, unsigned long size) |
|
188 |
+void cli_md5_update(cli_md5_ctx *ctx, const void *data, unsigned long size) |
|
189 | 189 |
{ |
190 | 190 |
MD5_u32plus saved_lo; |
191 | 191 |
unsigned long used, free; |
... | ... |
@@ -206,7 +206,7 @@ void cli_md5_update(cli_md5_ctx *ctx, void *data, unsigned long size) |
206 | 206 |
} |
207 | 207 |
|
208 | 208 |
memcpy(&ctx->buffer[used], data, free); |
209 |
- data = (unsigned char *)data + free; |
|
209 |
+ data = (const unsigned char *)data + free; |
|
210 | 210 |
size -= free; |
211 | 211 |
body(ctx, ctx->buffer, 64); |
212 | 212 |
} |
... | ... |
@@ -22,7 +22,7 @@ typedef struct { |
22 | 22 |
} cli_md5_ctx; |
23 | 23 |
|
24 | 24 |
extern void cli_md5_init(cli_md5_ctx *ctx); |
25 |
-extern void cli_md5_update(cli_md5_ctx *ctx, void *data, unsigned long size); |
|
25 |
+extern void cli_md5_update(cli_md5_ctx *ctx, const void *data, unsigned long size); |
|
26 | 26 |
extern void cli_md5_final(unsigned char *result, cli_md5_ctx *ctx); |
27 | 27 |
|
28 | 28 |
#endif |
... | ... |
@@ -467,12 +467,12 @@ static void ole2_walk_property_tree(int fd, ole2_header_t *hdr, const char *dir, |
467 | 467 |
unsigned int rec_level, unsigned int *file_count, const struct cl_limits *limits) |
468 | 468 |
{ |
469 | 469 |
property_t prop_block[4]; |
470 |
- int32_t index, current_block, i; |
|
470 |
+ int32_t idx, current_block, i; |
|
471 | 471 |
char *dirname; |
472 | 472 |
|
473 | 473 |
current_block = hdr->prop_start; |
474 | 474 |
|
475 |
- if ((prop_index < 0) || (prop_index > hdr->max_block_no) || (rec_level > 100) || (*file_count > 100000)) { |
|
475 |
+ if ((prop_index < 0) || (prop_index > (int32_t) hdr->max_block_no) || (rec_level > 100) || (*file_count > 100000)) { |
|
476 | 476 |
return; |
477 | 477 |
} |
478 | 478 |
|
... | ... |
@@ -486,34 +486,34 @@ static void ole2_walk_property_tree(int fd, ole2_header_t *hdr, const char *dir, |
486 | 486 |
return; |
487 | 487 |
} |
488 | 488 |
|
489 |
- index = prop_index / 4; |
|
490 |
- for (i=0 ; i < index ; i++) { |
|
489 |
+ idx = prop_index / 4; |
|
490 |
+ for (i=0 ; i < idx ; i++) { |
|
491 | 491 |
current_block = ole2_get_next_block_number(fd, hdr, current_block); |
492 | 492 |
if (current_block < 0) { |
493 | 493 |
return; |
494 | 494 |
} |
495 | 495 |
} |
496 |
- index = prop_index % 4; |
|
496 |
+ idx = prop_index % 4; |
|
497 | 497 |
if (!ole2_read_block(fd, hdr, prop_block, |
498 | 498 |
current_block)) { |
499 | 499 |
return; |
500 | 500 |
} |
501 |
- if (prop_block[index].type <= 0) { |
|
501 |
+ if (prop_block[idx].type <= 0) { |
|
502 | 502 |
return; |
503 | 503 |
} |
504 |
- prop_block[index].name_size = ole2_endian_convert_16(prop_block[index].name_size); |
|
505 |
- prop_block[index].prev = ole2_endian_convert_32(prop_block[index].prev); |
|
506 |
- prop_block[index].next = ole2_endian_convert_32(prop_block[index].next); |
|
507 |
- prop_block[index].child = ole2_endian_convert_32(prop_block[index].child); |
|
508 |
- prop_block[index].user_flags = ole2_endian_convert_32(prop_block[index].user_flags); |
|
509 |
- prop_block[index].create_lowdate = ole2_endian_convert_32(prop_block[index].create_lowdate); |
|
510 |
- prop_block[index].create_highdate = ole2_endian_convert_32(prop_block[index].create_highdate); |
|
511 |
- prop_block[index].mod_lowdate = ole2_endian_convert_32(prop_block[index].mod_lowdate); |
|
512 |
- prop_block[index].mod_highdate = ole2_endian_convert_32(prop_block[index].mod_highdate); |
|
513 |
- prop_block[index].start_block = ole2_endian_convert_32(prop_block[index].start_block); |
|
514 |
- prop_block[index].size = ole2_endian_convert_32(prop_block[index].size); |
|
504 |
+ prop_block[idx].name_size = ole2_endian_convert_16(prop_block[idx].name_size); |
|
505 |
+ prop_block[idx].prev = ole2_endian_convert_32(prop_block[idx].prev); |
|
506 |
+ prop_block[idx].next = ole2_endian_convert_32(prop_block[idx].next); |
|
507 |
+ prop_block[idx].child = ole2_endian_convert_32(prop_block[idx].child); |
|
508 |
+ prop_block[idx].user_flags = ole2_endian_convert_32(prop_block[idx].user_flags); |
|
509 |
+ prop_block[idx].create_lowdate = ole2_endian_convert_32(prop_block[idx].create_lowdate); |
|
510 |
+ prop_block[idx].create_highdate = ole2_endian_convert_32(prop_block[idx].create_highdate); |
|
511 |
+ prop_block[idx].mod_lowdate = ole2_endian_convert_32(prop_block[idx].mod_lowdate); |
|
512 |
+ prop_block[idx].mod_highdate = ole2_endian_convert_32(prop_block[idx].mod_highdate); |
|
513 |
+ prop_block[idx].start_block = ole2_endian_convert_32(prop_block[idx].start_block); |
|
514 |
+ prop_block[idx].size = ole2_endian_convert_32(prop_block[idx].size); |
|
515 | 515 |
|
516 |
- print_ole2_property(&prop_block[index]); |
|
516 |
+ print_ole2_property(&prop_block[idx]); |
|
517 | 517 |
|
518 | 518 |
/* Check we aren't in a loop */ |
519 | 519 |
if (cli_bitset_test(hdr->bitset, (unsigned long) prop_index)) { |
... | ... |
@@ -525,7 +525,7 @@ static void ole2_walk_property_tree(int fd, ole2_header_t *hdr, const char *dir, |
525 | 525 |
return; |
526 | 526 |
} |
527 | 527 |
|
528 |
- switch (prop_block[index].type) { |
|
528 |
+ switch (prop_block[idx].type) { |
|
529 | 529 |
case 5: /* Root Entry */ |
530 | 530 |
if ((prop_index != 0) || (rec_level !=0) || |
531 | 531 |
(*file_count != 0)) { |
... | ... |
@@ -533,17 +533,17 @@ static void ole2_walk_property_tree(int fd, ole2_header_t *hdr, const char *dir, |
533 | 533 |
cli_dbgmsg("ERROR: illegal Root Entry\n"); |
534 | 534 |
return; |
535 | 535 |
} |
536 |
- hdr->sbat_root_start = prop_block[index].start_block; |
|
536 |
+ hdr->sbat_root_start = prop_block[idx].start_block; |
|
537 | 537 |
ole2_walk_property_tree(fd, hdr, dir, |
538 |
- prop_block[index].prev, handler, rec_level+1, file_count, limits); |
|
538 |
+ prop_block[idx].prev, handler, rec_level+1, file_count, limits); |
|
539 | 539 |
ole2_walk_property_tree(fd, hdr, dir, |
540 |
- prop_block[index].next, handler, rec_level+1, file_count, limits); |
|
540 |
+ prop_block[idx].next, handler, rec_level+1, file_count, limits); |
|
541 | 541 |
ole2_walk_property_tree(fd, hdr, dir, |
542 |
- prop_block[index].child, handler, rec_level+1, file_count, limits); |
|
542 |
+ prop_block[idx].child, handler, rec_level+1, file_count, limits); |
|
543 | 543 |
break; |
544 | 544 |
case 2: /* File */ |
545 | 545 |
(*file_count)++; |
546 |
- if (!handler(fd, hdr, &prop_block[index], dir)) { |
|
546 |
+ if (!handler(fd, hdr, &prop_block[idx], dir)) { |
|
547 | 547 |
cli_dbgmsg("ERROR: handler failed\n"); |
548 | 548 |
/* If we don't return on this error then |
549 | 549 |
we can sometimes pull VBA code |
... | ... |
@@ -552,11 +552,11 @@ static void ole2_walk_property_tree(int fd, ole2_header_t *hdr, const char *dir, |
552 | 552 |
|
553 | 553 |
} |
554 | 554 |
ole2_walk_property_tree(fd, hdr, dir, |
555 |
- prop_block[index].prev, handler, rec_level, file_count, limits); |
|
555 |
+ prop_block[idx].prev, handler, rec_level, file_count, limits); |
|
556 | 556 |
ole2_walk_property_tree(fd, hdr, dir, |
557 |
- prop_block[index].next, handler, rec_level, file_count, limits); |
|
557 |
+ prop_block[idx].next, handler, rec_level, file_count, limits); |
|
558 | 558 |
ole2_walk_property_tree(fd, hdr, dir, |
559 |
- prop_block[index].child, handler, rec_level, file_count, limits); |
|
559 |
+ prop_block[idx].child, handler, rec_level, file_count, limits); |
|
560 | 560 |
break; |
561 | 561 |
case 1: /* Directory */ |
562 | 562 |
dirname = (char *) cli_malloc(strlen(dir)+8); |
... | ... |
@@ -570,15 +570,15 @@ static void ole2_walk_property_tree(int fd, ole2_header_t *hdr, const char *dir, |
570 | 570 |
} |
571 | 571 |
cli_dbgmsg("OLE2 dir entry: %s\n",dirname); |
572 | 572 |
ole2_walk_property_tree(fd, hdr, dir, |
573 |
- prop_block[index].prev, handler, rec_level+1, file_count, limits); |
|
573 |
+ prop_block[idx].prev, handler, rec_level+1, file_count, limits); |
|
574 | 574 |
ole2_walk_property_tree(fd, hdr, dir, |
575 |
- prop_block[index].next, handler, rec_level+1, file_count, limits); |
|
575 |
+ prop_block[idx].next, handler, rec_level+1, file_count, limits); |
|
576 | 576 |
ole2_walk_property_tree(fd, hdr, dirname, |
577 |
- prop_block[index].child, handler, rec_level+1, file_count, limits); |
|
577 |
+ prop_block[idx].child, handler, rec_level+1, file_count, limits); |
|
578 | 578 |
free(dirname); |
579 | 579 |
break; |
580 | 580 |
default: |
581 |
- cli_dbgmsg("ERROR: unknown OLE2 entry type: %d\n", prop_block[index].type); |
|
581 |
+ cli_dbgmsg("ERROR: unknown OLE2 entry type: %d\n", prop_block[idx].type); |
|
582 | 582 |
break; |
583 | 583 |
} |
584 | 584 |
return; |
... | ... |
@@ -648,7 +648,7 @@ static int handler_writefile(int fd, ole2_header_t *hdr, property_t *prop, const |
648 | 648 |
return FALSE; |
649 | 649 |
} |
650 | 650 |
while((current_block >= 0) && (len > 0)) { |
651 |
- if (current_block > hdr->max_block_no) { |
|
651 |
+ if (current_block > (int32_t) hdr->max_block_no) { |
|
652 | 652 |
cli_dbgmsg("OLE2: Max block number for file size exceeded: %d\n", current_block); |
653 | 653 |
close(ofd); |
654 | 654 |
free(buff); |
... | ... |
@@ -870,7 +870,7 @@ int cli_ole2_extract(int fd, const char *dirname, const struct cl_limits *limits |
870 | 870 |
hdr.max_block_no = ((statbuf.st_size / hdr.log2_big_block_size) + 1) * 8; |
871 | 871 |
|
872 | 872 |
print_ole2_header(&hdr); |
873 |
- cli_dbgmsg("Max block number: %lu\n", hdr.max_block_no); |
|
873 |
+ cli_dbgmsg("Max block number: %lu\n", (unsigned long int) hdr.max_block_no); |
|
874 | 874 |
|
875 | 875 |
/* NOTE: Select only ONE of the following two methods */ |
876 | 876 |
|
... | ... |
@@ -1,4 +1,7 @@ |
1 | 1 |
/* |
2 |
+ * Copyright (C) 2007 - 2008 Sourcefire, Inc. |
|
3 |
+ * Author: Tomasz Kojm <tkojm@clamav.net> |
|
4 |
+ * |
|
2 | 5 |
* Copyright (C) 1999 - 2005 Tomasz Kojm <tkojm@clamav.net> |
3 | 6 |
* |
4 | 7 |
* This program is free software; you can redistribute it and/or modify |
... | ... |
@@ -279,7 +282,7 @@ static char *cli_md5buff(const unsigned char *buffer, unsigned int len, unsigned |
279 | 279 |
|
280 | 280 |
|
281 | 281 |
cli_md5_init(&ctx); |
282 |
- cli_md5_update(&ctx, buffer, len); |
|
282 |
+ cli_md5_update(&ctx, (char *) buffer, len); |
|
283 | 283 |
cli_md5_final(digest, &ctx); |
284 | 284 |
|
285 | 285 |
if(dig) |
... | ... |
@@ -304,7 +307,7 @@ void *cli_malloc(size_t size) |
304 | 304 |
|
305 | 305 |
|
306 | 306 |
if(!size || size > CLI_MAX_ALLOCATION) { |
307 |
- cli_errmsg("cli_malloc(): Attempt to allocate %u bytes. Please report to http://bugs.clamav.net\n", size); |
|
307 |
+ cli_errmsg("cli_malloc(): Attempt to allocate %lu bytes. Please report to http://bugs.clamav.net\n", (unsigned long int) size); |
|
308 | 308 |
return NULL; |
309 | 309 |
} |
310 | 310 |
|
... | ... |
@@ -315,7 +318,7 @@ void *cli_malloc(size_t size) |
315 | 315 |
#endif |
316 | 316 |
|
317 | 317 |
if(!alloc) { |
318 |
- cli_errmsg("cli_malloc(): Can't allocate memory (%u bytes).\n", size); |
|
318 |
+ cli_errmsg("cli_malloc(): Can't allocate memory (%lu bytes).\n", (unsigned long int) size); |
|
319 | 319 |
perror("malloc_problem"); |
320 | 320 |
return NULL; |
321 | 321 |
} else return alloc; |
... | ... |
@@ -327,7 +330,7 @@ void *cli_calloc(size_t nmemb, size_t size) |
327 | 327 |
|
328 | 328 |
|
329 | 329 |
if(!size || size > CLI_MAX_ALLOCATION) { |
330 |
- cli_errmsg("cli_calloc(): Attempt to allocate %u bytes. Please report to http://bugs.clamav.net\n", size); |
|
330 |
+ cli_errmsg("cli_calloc(): Attempt to allocate %lu bytes. Please report to http://bugs.clamav.net\n", (unsigned long int) size); |
|
331 | 331 |
return NULL; |
332 | 332 |
} |
333 | 333 |
|
... | ... |
@@ -338,7 +341,7 @@ void *cli_calloc(size_t nmemb, size_t size) |
338 | 338 |
#endif |
339 | 339 |
|
340 | 340 |
if(!alloc) { |
341 |
- cli_errmsg("cli_calloc(): Can't allocate memory (%u bytes).\n", nmemb * size); |
|
341 |
+ cli_errmsg("cli_calloc(): Can't allocate memory (%lu bytes).\n", (unsigned long int) (nmemb * size)); |
|
342 | 342 |
perror("calloc_problem"); |
343 | 343 |
return NULL; |
344 | 344 |
} else return alloc; |
... | ... |
@@ -350,14 +353,14 @@ void *cli_realloc(void *ptr, size_t size) |
350 | 350 |
|
351 | 351 |
|
352 | 352 |
if(!size || size > CLI_MAX_ALLOCATION) { |
353 |
- cli_errmsg("cli_realloc(): Attempt to allocate %u bytes. Please report to http://bugs.clamav.net\n", size); |
|
353 |
+ cli_errmsg("cli_realloc(): Attempt to allocate %lu bytes. Please report to http://bugs.clamav.net\n", (unsigned long int) size); |
|
354 | 354 |
return NULL; |
355 | 355 |
} |
356 | 356 |
|
357 | 357 |
alloc = realloc(ptr, size); |
358 | 358 |
|
359 | 359 |
if(!alloc) { |
360 |
- cli_errmsg("cli_realloc(): Can't re-allocate memory to %u bytes.\n", size); |
|
360 |
+ cli_errmsg("cli_realloc(): Can't re-allocate memory to %lu bytes.\n", (unsigned long int) size); |
|
361 | 361 |
perror("realloc_problem"); |
362 | 362 |
return NULL; |
363 | 363 |
} else return alloc; |
... | ... |
@@ -369,14 +372,14 @@ void *cli_realloc2(void *ptr, size_t size) |
369 | 369 |
|
370 | 370 |
|
371 | 371 |
if(!size || size > CLI_MAX_ALLOCATION) { |
372 |
- cli_errmsg("cli_realloc2(): Attempt to allocate %u bytes. Please report to http://bugs.clamav.net\n", size); |
|
372 |
+ cli_errmsg("cli_realloc2(): Attempt to allocate %lu bytes. Please report to http://bugs.clamav.net\n", (unsigned long int) size); |
|
373 | 373 |
return NULL; |
374 | 374 |
} |
375 | 375 |
|
376 | 376 |
alloc = realloc(ptr, size); |
377 | 377 |
|
378 | 378 |
if(!alloc) { |
379 |
- cli_errmsg("cli_realloc2(): Can't re-allocate memory to %u bytes.\n", size); |
|
379 |
+ cli_errmsg("cli_realloc2(): Can't re-allocate memory to %lu bytes.\n", (unsigned long int) size); |
|
380 | 380 |
perror("realloc_problem"); |
381 | 381 |
if(ptr) |
382 | 382 |
free(ptr); |
... | ... |
@@ -401,7 +404,7 @@ char *cli_strdup(const char *s) |
401 | 401 |
#endif |
402 | 402 |
|
403 | 403 |
if(!alloc) { |
404 |
- cli_errmsg("cli_strdup(): Can't allocate memory (%u bytes).\n", strlen(s)); |
|
404 |
+ cli_errmsg("cli_strdup(): Can't allocate memory (%u bytes).\n", (unsigned int) strlen(s)); |
|
405 | 405 |
perror("strdup_problem"); |
406 | 406 |
return NULL; |
407 | 407 |
} |
... | ... |
@@ -868,8 +871,10 @@ const char* cli_ctime(const time_t *timep, char *buf, const size_t bufsize) |
868 | 868 |
} |
869 | 869 |
#ifdef HAVE_CTIME_R |
870 | 870 |
# ifdef HAVE_CTIME_R_2 |
871 |
- char* y = ctime_r(timep, buf); |
|
872 |
- return y; |
|
871 |
+ { |
|
872 |
+ char* y = ctime_r(timep, buf); |
|
873 |
+ return y; |
|
874 |
+ } |
|
873 | 875 |
# else |
874 | 876 |
return ctime_r(timep, buf, bufsize); |
875 | 877 |
# endif |
... | ... |
@@ -881,7 +881,7 @@ static int cli_loadmd5(FILE *fs, struct cl_engine **engine, unsigned int *signo, |
881 | 881 |
static int cli_loadmd(FILE *fs, struct cl_engine **engine, unsigned int *signo, int type, unsigned int options, gzFile *gzs, unsigned int gzrsize) |
882 | 882 |
{ |
883 | 883 |
char buffer[FILEBUFF], *pt; |
884 |
- int line = 0, comments = 0, ret = 0, crc32; |
|
884 |
+ int line = 0, comments = 0, ret = 0, crc; |
|
885 | 885 |
struct cli_meta_node *new; |
886 | 886 |
|
887 | 887 |
|
... | ... |
@@ -971,12 +971,12 @@ static int cli_loadmd(FILE *fs, struct cl_engine **engine, unsigned int *signo, |
971 | 971 |
if(!strcmp(pt, "*")) { |
972 | 972 |
new->crc32 = 0; |
973 | 973 |
} else { |
974 |
- crc32 = cli_hex2num(pt); |
|
975 |
- if(crc32 == -1) { |
|
974 |
+ crc = cli_hex2num(pt); |
|
975 |
+ if(crc == -1) { |
|
976 | 976 |
ret = CL_EMALFDB; |
977 | 977 |
break; |
978 | 978 |
} |
979 |
- new->crc32 = (unsigned int) crc32; |
|
979 |
+ new->crc32 = (unsigned int) crc; |
|
980 | 980 |
} |
981 | 981 |
free(pt); |
982 | 982 |
} |
... | ... |
@@ -1321,9 +1321,3 @@ create_vba_project(int record_count, const char *dir) |
1321 | 1321 |
|
1322 | 1322 |
return ret; |
1323 | 1323 |
} |
1324 |
- |
|
1325 |
-static uint32_t |
|
1326 |
-sigtouint32(const unsigned char *fourbytes) |
|
1327 |
-{ |
|
1328 |
- return (uint32_t)((*fourbytes++ << 24) | (*fourbytes++ << 16) | (*fourbytes++ << 8) | *fourbytes); |
|
1329 |
-} |