... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Tue Apr 13 16:17:35 EEST 2010 (edwin) |
|
2 |
+------------------------------------- |
|
3 |
+ * clambc, clamd,clamdtop,libclamav,unit_tests: fix compiler warnings (bb #1872, |
|
4 |
+ bb #1934, bb #1935) |
|
5 |
+ |
|
1 | 6 |
Tue Apr 13 16:13:05 EEST 2010 (edwin) |
2 | 7 |
------------------------------------- |
3 | 8 |
* libclamav/c++: allow building with gcc 3.4.6 (bb #1934). |
... | ... |
@@ -237,7 +237,7 @@ int main(int argc, char *argv[]) |
237 | 237 |
const struct optstruct *opt; |
238 | 238 |
unsigned funcid=0, i; |
239 | 239 |
struct cli_all_bc bcs; |
240 |
- unsigned int fd = -1; |
|
240 |
+ int fd = -1; |
|
241 | 241 |
unsigned tracelevel; |
242 | 242 |
|
243 | 243 |
opts = optparse(NULL, argc, argv, 1, OPT_CLAMBC, 0, NULL); |
... | ... |
@@ -77,7 +77,6 @@ int scan_callback(struct stat *sb, char *filename, const char *msg, enum cli_ftw |
77 | 77 |
const char *virname; |
78 | 78 |
int ret; |
79 | 79 |
int type = scandata->type; |
80 |
- const struct optstruct *opt; |
|
81 | 80 |
|
82 | 81 |
/* detect disconnected socket, |
83 | 82 |
* this should NOT detect half-shutdown sockets (SHUT_WR) */ |
... | ... |
@@ -79,7 +79,7 @@ static void scanner_thread(void *arg) |
79 | 79 |
sigset_t sigset; |
80 | 80 |
#endif |
81 | 81 |
int ret; |
82 |
- unsigned virus=0, errors = 0; |
|
82 |
+ int virus=0, errors = 0; |
|
83 | 83 |
|
84 | 84 |
#ifndef _WIN32 |
85 | 85 |
/* ignore all signals */ |
... | ... |
@@ -251,7 +251,7 @@ static struct cl_engine *reload_db(struct cl_engine *engine, unsigned int dbopti |
251 | 251 |
*/ |
252 | 252 |
static const char *get_cmd(struct fd_buf *buf, size_t off, size_t *len, char *term, int *oldstyle) |
253 | 253 |
{ |
254 |
- unsigned char *pos; |
|
254 |
+ char *pos; |
|
255 | 255 |
if (!buf->off || off >= buf->off) { |
256 | 256 |
*len = 0; |
257 | 257 |
return NULL; |
... | ... |
@@ -466,9 +466,9 @@ static void *acceptloop_th(void *arg) |
466 | 466 |
return NULL; |
467 | 467 |
} |
468 | 468 |
|
469 |
-static const unsigned char* parse_dispatch_cmd(client_conn_t *conn, struct fd_buf *buf, size_t *ppos, int *error, const struct optstruct *opts, int readtimeout) |
|
469 |
+static const char* parse_dispatch_cmd(client_conn_t *conn, struct fd_buf *buf, size_t *ppos, int *error, const struct optstruct *opts, int readtimeout) |
|
470 | 470 |
{ |
471 |
- const unsigned char *cmd = NULL; |
|
471 |
+ const char *cmd = NULL; |
|
472 | 472 |
int rc; |
473 | 473 |
size_t cmdlen; |
474 | 474 |
char term; |
... | ... |
@@ -1164,7 +1164,7 @@ int recvloop_th(int *socketds, unsigned nsockets, struct cl_engine *engine, unsi |
1164 | 1164 |
while (!error && buf->fd != -1 && buf->buffer && pos < buf->off && |
1165 | 1165 |
buf->mode != MODE_WAITANCILL) { |
1166 | 1166 |
client_conn_t conn; |
1167 |
- const unsigned char *cmd = NULL; |
|
1167 |
+ const char *cmd = NULL; |
|
1168 | 1168 |
int rc; |
1169 | 1169 |
/* New data available to read on socket. */ |
1170 | 1170 |
|
... | ... |
@@ -326,6 +326,9 @@ int command(client_conn_t *conn, int *virus) |
326 | 326 |
conn->scanfd = -1; |
327 | 327 |
cli_unlink(conn->filename); |
328 | 328 |
return ret; |
329 |
+ default: |
|
330 |
+ logg("!Invalid command distpached: %d\n", conn->cmdtype); |
|
331 |
+ return 1; |
|
329 | 332 |
} |
330 | 333 |
|
331 | 334 |
scandata.type = type; |
... | ... |
@@ -413,6 +416,10 @@ static int dispatch_command(client_conn_t *conn, enum commands cmd, const char * |
413 | 413 |
bulk = 0; |
414 | 414 |
/* just dispatch the command */ |
415 | 415 |
break; |
416 |
+ default: |
|
417 |
+ logg("!Invalid command dispatch: %d\n", cmd); |
|
418 |
+ ret = -2; |
|
419 |
+ break; |
|
416 | 420 |
} |
417 | 421 |
if (!dup_conn->group) |
418 | 422 |
bulk = 0; |
... | ... |
@@ -1133,7 +1133,6 @@ static void setup_connections(int argc, char *argv[]) |
1133 | 1133 |
default_colors = 1; |
1134 | 1134 |
memset(&global, 0, sizeof(global)); |
1135 | 1135 |
if (!opts->filename || !opts->filename[0]) { |
1136 |
- char *aargv[2]; |
|
1137 | 1136 |
const struct optstruct *opt; |
1138 | 1137 |
const char *clamd_conf = optget(opts, "config-file")->strarg; |
1139 | 1138 |
|
... | ... |
@@ -418,7 +418,7 @@ static inline operand_t readOperand(struct cli_bc_func *func, unsigned char *p, |
418 | 418 |
return v; |
419 | 419 |
} |
420 | 420 |
|
421 |
-static inline unsigned char *readData(const unsigned char *p, unsigned *off, unsigned len, char *ok, unsigned *datalen) |
|
421 |
+static inline char *readData(const unsigned char *p, unsigned *off, unsigned len, char *ok, unsigned *datalen) |
|
422 | 422 |
{ |
423 | 423 |
unsigned char *dat, *q; |
424 | 424 |
unsigned l, newoff, i; |
... | ... |
@@ -458,13 +458,13 @@ static inline unsigned char *readData(const unsigned char *p, unsigned *off, uns |
458 | 458 |
} |
459 | 459 |
*off = newoff; |
460 | 460 |
*datalen = l; |
461 |
- return dat; |
|
461 |
+ return (char*)dat; |
|
462 | 462 |
} |
463 | 463 |
|
464 | 464 |
static inline char *readString(const unsigned char *p, unsigned *off, unsigned len, char *ok) |
465 | 465 |
{ |
466 | 466 |
unsigned stringlen; |
467 |
- char *str = (char*)readData(p, off, len, ok, &stringlen); |
|
467 |
+ char *str = readData(p, off, len, ok, &stringlen); |
|
468 | 468 |
if (*ok && stringlen && str[stringlen-1] != '\0') { |
469 | 469 |
str[stringlen-1] = '\0'; |
470 | 470 |
cli_errmsg("bytecode: string missing \\0 terminator: %s\n", str); |
... | ... |
@@ -529,7 +529,7 @@ static int parseHeader(struct cli_bc *bc, unsigned char *buffer, unsigned *linel |
529 | 529 |
return CL_EMALFDB; |
530 | 530 |
} |
531 | 531 |
offset++; |
532 |
- *linelength = strtol(buffer+offset, &pos, 10); |
|
532 |
+ *linelength = strtol((const char*)buffer+offset, &pos, 10); |
|
533 | 533 |
if (*pos != '\0') { |
534 | 534 |
cli_errmsg("Invalid number: %s\n", buffer+offset); |
535 | 535 |
return CL_EMALFDB; |
... | ... |
@@ -548,7 +548,7 @@ static int parseHeader(struct cli_bc *bc, unsigned char *buffer, unsigned *linel |
548 | 548 |
return CL_SUCCESS; |
549 | 549 |
} |
550 | 550 |
|
551 |
-static int parseLSig(struct cli_bc *bc, unsigned char *buffer) |
|
551 |
+static int parseLSig(struct cli_bc *bc, char *buffer) |
|
552 | 552 |
{ |
553 | 553 |
const char *prefix; |
554 | 554 |
char *vnames, *vend = strchr(buffer, ';'); |
... | ... |
@@ -920,7 +920,7 @@ static int parseGlobals(struct cli_bc *bc, unsigned char *buffer) |
920 | 920 |
|
921 | 921 |
static int parseMD(struct cli_bc *bc, unsigned char *buffer) |
922 | 922 |
{ |
923 |
- unsigned offset = 1, len = strlen(buffer); |
|
923 |
+ unsigned offset = 1, len = strlen((const char*)buffer); |
|
924 | 924 |
unsigned numMD, i, b; |
925 | 925 |
char ok = 1; |
926 | 926 |
if (buffer[0] != 'D') |
... | ... |
@@ -1345,7 +1345,7 @@ int cli_bytecode_load(struct cli_bc *bc, FILE *f, struct cli_dbio *dbio, int tru |
1345 | 1345 |
row++; |
1346 | 1346 |
switch (state) { |
1347 | 1347 |
case PARSE_BC_LSIG: |
1348 |
- rc = parseLSig(bc, (unsigned char*)buffer); |
|
1348 |
+ rc = parseLSig(bc, buffer); |
|
1349 | 1349 |
if (rc == CL_BREAK) /* skip */ { |
1350 | 1350 |
bc->state = bc_skip; |
1351 | 1351 |
free(buffer); |
... | ... |
@@ -120,15 +120,15 @@ uint32_t cli_bcapi_debug_print_uint(struct cli_bc_ctx *ctx, uint32_t a) |
120 | 120 |
* executing */ |
121 | 121 |
uint32_t cli_bcapi_setvirusname(struct cli_bc_ctx* ctx, const uint8_t *name, uint32_t len) |
122 | 122 |
{ |
123 |
- ctx->virname = name; |
|
123 |
+ ctx->virname = (const char*)name; |
|
124 | 124 |
return 0; |
125 | 125 |
} |
126 | 126 |
|
127 | 127 |
uint32_t cli_bcapi_disasm_x86(struct cli_bc_ctx *ctx, struct DISASM_RESULT *res, uint32_t len) |
128 | 128 |
{ |
129 | 129 |
int n; |
130 |
- const char *buf; |
|
131 |
- const char* next; |
|
130 |
+ const unsigned char *buf; |
|
131 |
+ const unsigned char* next; |
|
132 | 132 |
if (!res || !ctx->fmap || ctx->off >= ctx->fmap->len) |
133 | 133 |
return -1; |
134 | 134 |
/* 32 should be longest instr we support decoding. |
... | ... |
@@ -262,7 +262,7 @@ uint32_t cli_bcapi_trace_value(struct cli_bc_ctx *ctx, const uint8_t* name, uint |
262 | 262 |
ctx->trace(ctx, trace_param); |
263 | 263 |
} |
264 | 264 |
if (ctx->trace_val && name) |
265 |
- ctx->trace_val(ctx, name, value); |
|
265 |
+ ctx->trace_val(ctx, (const char*)name, value); |
|
266 | 266 |
return 0; |
267 | 267 |
} |
268 | 268 |
|
... | ... |
@@ -283,7 +283,7 @@ uint32_t cli_bcapi_trace_ptr(struct cli_bc_ctx *ctx, const uint8_t* ptr, uint32_ |
283 | 283 |
uint32_t cli_bcapi_pe_rawaddr(struct cli_bc_ctx *ctx, uint32_t rva) |
284 | 284 |
{ |
285 | 285 |
uint32_t ret; |
286 |
- int err = 0; |
|
286 |
+ unsigned err = 0; |
|
287 | 287 |
const struct cli_pe_hook_data *pe = ctx->hooks.pedata; |
288 | 288 |
ret = cli_rawaddr(rva, ctx->sections, pe->nsections, &err, |
289 | 289 |
ctx->file_size, pe->hdr_size); |
... | ... |
@@ -323,7 +323,7 @@ int32_t cli_bcapi_file_find(struct cli_bc_ctx *ctx, const uint8_t* data, uint32_ |
323 | 323 |
{ |
324 | 324 |
char buf[4096]; |
325 | 325 |
fmap_t *map = ctx->fmap; |
326 |
- uint32_t off = ctx->off, newoff; |
|
326 |
+ uint32_t off = ctx->off; |
|
327 | 327 |
int n; |
328 | 328 |
|
329 | 329 |
if (!map || len > sizeof(buf)/4 || len <= 0) { |
... | ... |
@@ -421,7 +421,7 @@ int32_t cli_bcapi_fill_buffer(struct cli_bc_ctx *ctx, uint8_t* buf, |
421 | 421 |
int32_t cli_bcapi_extract_new(struct cli_bc_ctx *ctx, int32_t id) |
422 | 422 |
{ |
423 | 423 |
cli_ctx *cctx; |
424 |
- int res; |
|
424 |
+ int res = -1; |
|
425 | 425 |
cli_dbgmsg("previous tempfile had %u bytes\n", ctx->written); |
426 | 426 |
if (!ctx->written) |
427 | 427 |
return 0; |
... | ... |
@@ -453,7 +453,6 @@ int32_t cli_bcapi_extract_new(struct cli_bc_ctx *ctx, int32_t id) |
453 | 453 |
#define BUF 16 |
454 | 454 |
int32_t cli_bcapi_read_number(struct cli_bc_ctx *ctx, uint32_t radix) |
455 | 455 |
{ |
456 |
- unsigned char number[16]; |
|
457 | 456 |
unsigned i; |
458 | 457 |
char *p; |
459 | 458 |
int32_t result; |
... | ... |
@@ -864,7 +863,7 @@ static struct bc_jsnorm *get_jsnorm(struct cli_bc_ctx *ctx, int32_t id) |
864 | 864 |
int32_t cli_bcapi_jsnorm_process(struct cli_bc_ctx *ctx, int32_t id) |
865 | 865 |
{ |
866 | 866 |
unsigned avail; |
867 |
- char *in; |
|
867 |
+ unsigned char *in; |
|
868 | 868 |
cli_ctx *cctx = ctx->ctx; |
869 | 869 |
struct bc_jsnorm *b = get_jsnorm(ctx, id); |
870 | 870 |
if (!b || b->from == -1 || !b->state) |
... | ... |
@@ -877,7 +876,7 @@ int32_t cli_bcapi_jsnorm_process(struct cli_bc_ctx *ctx, int32_t id) |
877 | 877 |
if (cctx && cli_checklimits("bytecode js api", cctx, ctx->jsnormwritten + avail, 0, 0)) |
878 | 878 |
return -1; |
879 | 879 |
cli_bcapi_buffer_pipe_read_stopped(ctx, b->from, avail); |
880 |
- cli_js_process_buffer(b->state, in, avail); |
|
880 |
+ cli_js_process_buffer(b->state, (char*)in, avail); |
|
881 | 881 |
return 0; |
882 | 882 |
} |
883 | 883 |
|
... | ... |
@@ -395,7 +395,7 @@ static always_inline struct stack_entry *pop_stack(struct stack *stack, |
395 | 395 |
|
396 | 396 |
#define CHECK_OP(cond, msg) if((cond)) { cli_dbgmsg(msg); stop = CL_EBYTECODE; break;} |
397 | 397 |
|
398 |
-#define DEFINE_CASTOP(opc, OP) \ |
|
398 |
+#define DEFINE_SCASTOP(opc, OP) \ |
|
399 | 399 |
case opc*5: {\ |
400 | 400 |
uint8_t res;\ |
401 | 401 |
int8_t sres;\ |
... | ... |
@@ -431,6 +431,7 @@ static always_inline struct stack_entry *pop_stack(struct stack *stack, |
431 | 431 |
WRITE64(inst->dest, res);\ |
432 | 432 |
break;\ |
433 | 433 |
} |
434 |
+#define DEFINE_CASTOP(opc, OP) DEFINE_SCASTOP(opc, OP; (void)sres) |
|
434 | 435 |
|
435 | 436 |
#define DEFINE_OP(opc) \ |
436 | 437 |
case opc*5: /* fall-through */\ |
... | ... |
@@ -490,7 +491,7 @@ static inline int32_t ptr_diff32(int64_t ptr1, int64_t ptr2) |
490 | 490 |
int32_t ptrid1 = ptr1 >> 32; |
491 | 491 |
int32_t ptrid2 = ptr2 >> 32; |
492 | 492 |
if (ptrid1 != ptrid2) { |
493 |
- bcfail("difference of pointers not pointing to same object!", ptrid1, ptrid2, __FILE__, __LINE__); |
|
493 |
+ (void)bcfail("difference of pointers not pointing to same object!", ptrid1, ptrid2, __FILE__, __LINE__); |
|
494 | 494 |
/* invalid diff */ |
495 | 495 |
return 0x40000000; |
496 | 496 |
} |
... | ... |
@@ -498,10 +499,9 @@ static inline int32_t ptr_diff32(int64_t ptr1, int64_t ptr2) |
498 | 498 |
} |
499 | 499 |
|
500 | 500 |
static inline int64_t ptr_register_stack(struct ptr_infos *infos, |
501 |
- unsigned char *values, |
|
501 |
+ char *values, |
|
502 | 502 |
uint32_t off, uint32_t size) |
503 | 503 |
{ |
504 |
- int16_t id; |
|
505 | 504 |
unsigned n = infos->nstacks + 1; |
506 | 505 |
struct ptr_info *sinfos = cli_realloc(infos->stack_infos, |
507 | 506 |
sizeof(*sinfos)*n); |
... | ... |
@@ -510,7 +510,7 @@ static inline int64_t ptr_register_stack(struct ptr_infos *infos, |
510 | 510 |
infos->stack_infos = sinfos; |
511 | 511 |
infos->nstacks = n; |
512 | 512 |
sinfos = &sinfos[n-1]; |
513 |
- sinfos->base = values + off; |
|
513 |
+ sinfos->base = (uint8_t*)values + off; |
|
514 | 514 |
sinfos->size = size; |
515 | 515 |
return ptr_compose(-n, 0); |
516 | 516 |
} |
... | ... |
@@ -556,20 +556,20 @@ static inline void* ptr_torealptr(const struct ptr_infos *infos, int64_t ptr, |
556 | 556 |
int32_t ptrid = ptr >> 32; |
557 | 557 |
uint32_t ptroff = (uint32_t)ptr; |
558 | 558 |
if (UNLIKELY(!ptrid)) { |
559 |
- bcfail("nullptr", ptrid, 0, __FILE__, __LINE__); |
|
559 |
+ (void)bcfail("nullptr", ptrid, 0, __FILE__, __LINE__); |
|
560 | 560 |
return NULL; |
561 | 561 |
} |
562 | 562 |
if (ptrid < 0) { |
563 | 563 |
ptrid = -ptrid-1; |
564 | 564 |
if (UNLIKELY(ptrid >= infos->nstacks)) { |
565 |
- bcfail("ptr", ptrid, infos->nstacks, __FILE__, __LINE__); |
|
565 |
+ (void)bcfail("ptr", ptrid, infos->nstacks, __FILE__, __LINE__); |
|
566 | 566 |
return NULL; |
567 | 567 |
} |
568 | 568 |
info = &infos->stack_infos[ptrid]; |
569 | 569 |
} else { |
570 | 570 |
ptrid--; |
571 | 571 |
if (UNLIKELY(ptrid >= infos->nglobs)) { |
572 |
- bcfail("ptr", ptrid, infos->nglobs, __FILE__, __LINE__); |
|
572 |
+ (void)bcfail("ptr", ptrid, infos->nglobs, __FILE__, __LINE__); |
|
573 | 573 |
return NULL; |
574 | 574 |
} |
575 | 575 |
info = &infos->glob_infos[ptrid]; |
... | ... |
@@ -580,9 +580,9 @@ static inline void* ptr_torealptr(const struct ptr_infos *infos, int64_t ptr, |
580 | 580 |
return info->base+ptroff; |
581 | 581 |
} |
582 | 582 |
|
583 |
- bcfail("ptr1", ptroff, info->size, __FILE__, __LINE__); |
|
584 |
- bcfail("ptr2", read_size, info->size, __FILE__, __LINE__); |
|
585 |
- bcfail("ptr3", ptroff+read_size, info->size, __FILE__, __LINE__); |
|
583 |
+ (void)bcfail("ptr1", ptroff, info->size, __FILE__, __LINE__); |
|
584 |
+ (void)bcfail("ptr2", read_size, info->size, __FILE__, __LINE__); |
|
585 |
+ (void)bcfail("ptr3", ptroff+read_size, info->size, __FILE__, __LINE__); |
|
586 | 586 |
return NULL; |
587 | 587 |
} |
588 | 588 |
|
... | ... |
@@ -610,8 +610,9 @@ static unsigned globaltypesize(uint16_t id) |
610 | 610 |
s += globaltypesize(ty->containedTypes[i]); |
611 | 611 |
return s; |
612 | 612 |
} |
613 |
+ default: |
|
614 |
+ return 0; |
|
613 | 615 |
} |
614 |
- return 0; |
|
615 | 616 |
} |
616 | 617 |
|
617 | 618 |
int cli_vm_execute(const struct cli_bc *bc, struct cli_bc_ctx *ctx, const struct cli_bc_func *func, const struct cli_bc_inst *inst) |
... | ... |
@@ -685,7 +686,7 @@ int cli_vm_execute(const struct cli_bc *bc, struct cli_bc_ctx *ctx, const struct |
685 | 685 |
DEFINE_BINOP(OP_BC_OR, res = op0 | op1); |
686 | 686 |
DEFINE_BINOP(OP_BC_XOR, res = op0 ^ op1); |
687 | 687 |
|
688 |
- DEFINE_CASTOP(OP_BC_SEXT, |
|
688 |
+ DEFINE_SCASTOP(OP_BC_SEXT, |
|
689 | 689 |
CHOOSE(READ1(sres, inst->u.cast.source); res = sres ? ~0ull : 0, |
690 | 690 |
READ8(sres, inst->u.cast.source); res=sres=SIGNEXT(sres, inst->u.cast.mask), |
691 | 691 |
READ16(sres, inst->u.cast.source); res=sres=SIGNEXT(sres, inst->u.cast.mask), |
... | ... |
@@ -788,7 +789,7 @@ int cli_vm_execute(const struct cli_bc *bc, struct cli_bc_ctx *ctx, const struct |
788 | 788 |
TRACE_API(api->name, inst->dest, inst->type, stack_depth); |
789 | 789 |
switch (api->kind) { |
790 | 790 |
case 0: { |
791 |
- int32_t a, b, r; |
|
791 |
+ int32_t a, b; |
|
792 | 792 |
READ32(a, inst->u.ops.ops[0]); |
793 | 793 |
READ32(b, inst->u.ops.ops[1]); |
794 | 794 |
res32 = cli_apicalls0[api->idx](ctx, a, b); |
... | ... |
@@ -1070,7 +1071,7 @@ int cli_vm_execute(const struct cli_bc *bc, struct cli_bc_ctx *ctx, const struct |
1070 | 1070 |
} |
1071 | 1071 |
DEFINE_OP(OP_BC_MEMCPY) { |
1072 | 1072 |
int32_t arg3; |
1073 |
- void *arg1, *arg2, *resp; |
|
1073 |
+ void *arg1, *arg2; |
|
1074 | 1074 |
int64_t res=0; |
1075 | 1075 |
|
1076 | 1076 |
READ32(arg3, inst->u.three[2]); |
... | ... |
@@ -1083,7 +1084,7 @@ int cli_vm_execute(const struct cli_bc *bc, struct cli_bc_ctx *ctx, const struct |
1083 | 1083 |
} |
1084 | 1084 |
DEFINE_OP(OP_BC_MEMMOVE) { |
1085 | 1085 |
int32_t arg3; |
1086 |
- void *arg1, *arg2, *resp; |
|
1086 |
+ void *arg1, *arg2; |
|
1087 | 1087 |
int64_t res=0; |
1088 | 1088 |
|
1089 | 1089 |
READ32(arg3, inst->u.three[2]); |
... | ... |
@@ -5,8 +5,6 @@ namespace llvm { |
5 | 5 |
class Pass; |
6 | 6 |
} |
7 | 7 |
namespace ClamBCModule { |
8 |
- static void stop(const char *msg, llvm::Function* F, llvm::Instruction* I) { |
|
9 |
- llvm::errs() << msg << "\n"; |
|
10 |
- } |
|
8 |
+ void stop(const char *msg, llvm::Function* F, llvm::Instruction* I); |
|
11 | 9 |
} |
12 | 10 |
llvm::Pass *createClamBCRTChecks(); |
... | ... |
@@ -1999,8 +1999,10 @@ void cli_bytecode_debug_printsrc(const struct cli_bc_ctx *ctx) |
1999 | 1999 |
return; |
2000 | 2000 |
} |
2001 | 2001 |
assert(ctx->line < lines->linev.size()); |
2002 |
- SMDiagnostic diag(ctx->file, ctx->line ? ctx->line : -1, |
|
2003 |
- ctx->col ? ctx->col-1 : -1, |
|
2002 |
+ |
|
2003 |
+ int line = (int)ctx->line ? (int)ctx->line : -1; |
|
2004 |
+ int col = (int)ctx->col ? (int)ctx->col : -1; |
|
2005 |
+ SMDiagnostic diag(ctx->file, line, col, |
|
2004 | 2006 |
"", std::string(lines->linev[ctx->line-1], lines->linev[ctx->line]-1)); |
2005 | 2007 |
diag.Print("[trace]", errs()); |
2006 | 2008 |
} |
... | ... |
@@ -2010,3 +2012,10 @@ void cli_bytecode_printversion() |
2010 | 2010 |
{ |
2011 | 2011 |
cl::PrintVersionMessage(); |
2012 | 2012 |
} |
2013 |
+ |
|
2014 |
+namespace ClamBCModule { |
|
2015 |
+void stop(const char *msg, llvm::Function* F, llvm::Instruction* I) |
|
2016 |
+{ |
|
2017 |
+ llvm::errs() << msg << "\n"; |
|
2018 |
+} |
|
2019 |
+} |
... | ... |
@@ -303,7 +303,6 @@ void LiveInterval::removeRange(SlotIndex Start, SlotIndex End, |
303 | 303 |
// otherwise mark it as ~1U so it can be nuked later. |
304 | 304 |
if (ValNo->id == getNumValNums()-1) { |
305 | 305 |
do { |
306 |
- VNInfo *VNI = valnos.back(); |
|
307 | 306 |
valnos.pop_back(); |
308 | 307 |
} while (!valnos.empty() && valnos.back()->isUnused()); |
309 | 308 |
} else { |
... | ... |
@@ -350,7 +349,6 @@ void LiveInterval::removeValNo(VNInfo *ValNo) { |
350 | 350 |
// otherwise mark it as ~1U so it can be nuked later. |
351 | 351 |
if (ValNo->id == getNumValNums()-1) { |
352 | 352 |
do { |
353 |
- VNInfo *VNI = valnos.back(); |
|
354 | 353 |
valnos.pop_back(); |
355 | 354 |
} while (!valnos.empty() && valnos.back()->isUnused()); |
356 | 355 |
} else { |
... | ... |
@@ -577,7 +575,6 @@ void LiveInterval::MergeValueInAsValue( |
577 | 577 |
// mark it as ~1U so it can be nuked later. |
578 | 578 |
if (V1->id == getNumValNums()-1) { |
579 | 579 |
do { |
580 |
- VNInfo *VNI = valnos.back(); |
|
581 | 580 |
valnos.pop_back(); |
582 | 581 |
} while (!valnos.empty() && valnos.back()->isUnused()); |
583 | 582 |
} else { |
... | ... |
@@ -745,7 +742,6 @@ VNInfo* LiveInterval::MergeValueNumberInto(VNInfo *V1, VNInfo *V2) { |
745 | 745 |
// ~1U so it can be nuked later. |
746 | 746 |
if (V1->id == getNumValNums()-1) { |
747 | 747 |
do { |
748 |
- VNInfo *VNI = valnos.back(); |
|
749 | 748 |
valnos.pop_back(); |
750 | 749 |
} while (valnos.back()->isUnused()); |
751 | 750 |
} else { |
... | ... |
@@ -412,7 +412,7 @@ int filter_add_acpatt(struct filter *m, const struct cli_ac_patt *pat) |
412 | 412 |
int32_t best_score = -0x7fffffff; |
413 | 413 |
unsigned best_score_i = 0; |
414 | 414 |
unsigned best_score_len = 0; |
415 |
- struct char_spec *spec0, *spec1; |
|
415 |
+ struct char_spec *spec0 = NULL, *spec1 = NULL; |
|
416 | 416 |
|
417 | 417 |
struct choice choices[MAX_CHOICES]; |
418 | 418 |
unsigned choices_cnt = 0; |
... | ... |
@@ -641,7 +641,8 @@ int filter_add_acpatt(struct filter *m, const struct cli_ac_patt *pat) |
641 | 641 |
} |
642 | 642 |
|
643 | 643 |
j = best_score_len - 2; |
644 |
- for (k0=spec0->start;k0 <= spec0->end;k0 += spec0->step) { |
|
644 |
+ if (spec0 && spec1) { |
|
645 |
+ for (k0=spec0->start;k0 <= spec0->end;k0 += spec0->step) { |
|
645 | 646 |
for (k1=spec1->start;k1 <= spec1->end;k1 += spec1->step) { |
646 | 647 |
unsigned char c0 = spec_ith_char(spec0, k0); |
647 | 648 |
unsigned char c1 = spec_ith_char(spec1, k1); |
... | ... |
@@ -650,6 +651,7 @@ int filter_add_acpatt(struct filter *m, const struct cli_ac_patt *pat) |
650 | 650 |
} |
651 | 651 |
filter_set_end(m, j, c0 | (c1<<8)); |
652 | 652 |
} |
653 |
+ } |
|
653 | 654 |
} |
654 | 655 |
return j+2; |
655 | 656 |
} |
... | ... |
@@ -699,7 +701,6 @@ __hot__ int filter_search_ext(const struct filter *m, const unsigned char *data, |
699 | 699 |
uint8_t state = ~0; |
700 | 700 |
const uint8_t *B = m->B; |
701 | 701 |
const uint8_t *End = m->end; |
702 |
- uint8_t shortest, longest=0; |
|
703 | 702 |
|
704 | 703 |
if (len < 2) return -1; |
705 | 704 |
/* look for first match */ |
... | ... |
@@ -1618,7 +1618,7 @@ int cli_ac_addsig(struct cli_matcher *root, const char *virname, const char *hex |
1618 | 1618 |
break; |
1619 | 1619 |
} |
1620 | 1620 |
|
1621 |
- if(!(c = cli_mpool_hex2str(root->mempool, h))) { |
|
1621 |
+ if(!(c = (char*)cli_mpool_hex2str(root->mempool, h))) { |
|
1622 | 1622 |
free(h); |
1623 | 1623 |
error = CL_EMALFDB; |
1624 | 1624 |
break; |
... | ... |
@@ -501,7 +501,7 @@ unsigned char *cli_mpool_hex2str(mpool_t *mp, const char *hex) { |
501 | 501 |
} |
502 | 502 |
|
503 | 503 |
str = mpool_malloc(mp, (len/2) + 1); |
504 |
- if (cli_hex2str_to(hex, str, len) == -1) { |
|
504 |
+ if (cli_hex2str_to(hex, (char*)str, len) == -1) { |
|
505 | 505 |
mpool_free(mp, str); |
506 | 506 |
return NULL; |
507 | 507 |
} |
... | ... |
@@ -511,7 +511,7 @@ int cli_scanpe(cli_ctx *ctx, icon_groupset *iconset) |
511 | 511 |
char *src = NULL, *dest = NULL; |
512 | 512 |
int ndesc, ret = CL_CLEAN, upack = 0, native=0; |
513 | 513 |
size_t fsize; |
514 |
- uint32_t valign, falign, hdr_size, j, offset; |
|
514 |
+ uint32_t valign, falign, hdr_size, j; |
|
515 | 515 |
struct cli_exe_section *exe_sections; |
516 | 516 |
struct cli_matcher *md5_sect; |
517 | 517 |
char timestr[32]; |
... | ... |
@@ -2571,11 +2571,11 @@ int cli_peheader(fmap_t *map, struct cli_exe_info *peinfo) |
2571 | 2571 |
char *k, *v, *s; |
2572 | 2572 |
|
2573 | 2573 |
/* FIXME: skip too long strings */ |
2574 |
- k = cli_utf16toascii(vptr + 6, s_key_sz); |
|
2574 |
+ k = cli_utf16toascii((const char*)vptr + 6, s_key_sz); |
|
2575 | 2575 |
if(k) { |
2576 |
- v = cli_utf16toascii(vptr + s_key_sz + 6, s_val_sz); |
|
2576 |
+ v = cli_utf16toascii((const char*)vptr + s_key_sz + 6, s_val_sz); |
|
2577 | 2577 |
if(v) { |
2578 |
- s = cli_str2hex(vptr + 6, s_key_sz + s_val_sz - 6); |
|
2578 |
+ s = cli_str2hex((const char*)vptr + 6, s_key_sz + s_val_sz - 6); |
|
2579 | 2579 |
if(s) { |
2580 | 2580 |
cli_dbgmsg("VersionInfo (%x): '%s'='%s' - VI:%s\n", (uint32_t)(vptr - baseptr + 6), k, v, s); |
2581 | 2581 |
free(s); |
... | ... |
@@ -563,6 +563,7 @@ static void lab(double r, double g, double b, double *L, double *A, double *B) { |
563 | 563 |
*B = 200.0f * (y - z); |
564 | 564 |
} |
565 | 565 |
|
566 |
+#ifndef USE_FLOATS |
|
566 | 567 |
static void lab2(uint32_t r, uint32_t g, uint32_t b, int32_t *L, int32_t *A, int32_t *B) { |
567 | 568 |
uint32_t xx,yy,zz; |
568 | 569 |
|
... | ... |
@@ -591,6 +592,7 @@ static void lab2(uint32_t r, uint32_t g, uint32_t b, int32_t *L, int32_t *A, int |
591 | 591 |
*A = 500/4*(xx - yy); |
592 | 592 |
*B = 200/4*(yy - zz);/* /4 to avoid overflow */ |
593 | 593 |
} |
594 |
+#endif |
|
594 | 595 |
|
595 | 596 |
static double labdiff(unsigned int rgb) { |
596 | 597 |
unsigned int r, g, b; |
... | ... |
@@ -606,6 +608,7 @@ static double labdiff(unsigned int rgb) { |
606 | 606 |
return sqrt(pow(L1 - L2, 2.0f) + pow(A1 - A2, 2.0f) + pow(B1 - B2, 2.0f)); |
607 | 607 |
} |
608 | 608 |
|
609 |
+#ifndef USE_FLOATS |
|
609 | 610 |
static uint32_t labdiff2(unsigned int b) { |
610 | 611 |
unsigned int r2, g2, b2; |
611 | 612 |
int32_t L1, A1, B1, L2, A2, B2; |
... | ... |
@@ -629,6 +632,7 @@ static uint32_t labdiff2(unsigned int b) { |
629 | 629 |
ld += ad + bd; |
630 | 630 |
return ((uint32_t)(sqrt(ld/1024.0)))>>17; |
631 | 631 |
} |
632 |
+#endif |
|
632 | 633 |
|
633 | 634 |
static void makebmp(const char *step, const char *tempd, int w, int h, void *data) { |
634 | 635 |
unsigned int tmp1, tmp2, tmp3, tmp4, y; |
... | ... |
@@ -1189,7 +1193,7 @@ static int parseicon(icon_groupset *set, uint32_t rva, cli_ctx *ctx, struct cli_ |
1189 | 1189 |
struct icomtr metrics; |
1190 | 1190 |
unsigned char *rawimage; |
1191 | 1191 |
const char *tempd; |
1192 |
- uint32_t *palette = NULL, *imagedata, *imagedata2; |
|
1192 |
+ uint32_t *palette = NULL, *imagedata; |
|
1193 | 1193 |
unsigned int scanlinesz, andlinesz; |
1194 | 1194 |
unsigned int width, height, depth, x, y; |
1195 | 1195 |
unsigned int err, scalemode = 2, enginesize; |
... | ... |
@@ -1651,7 +1651,7 @@ static int cli_loadinfo(FILE *fs, struct cl_engine *engine, unsigned int options |
1651 | 1651 |
ret = CL_EMEM; |
1652 | 1652 |
break; |
1653 | 1653 |
} |
1654 |
- new->name = (unsigned char *) cli_mpool_strdup(engine->mempool, tokens[0]); |
|
1654 |
+ new->name = cli_mpool_strdup(engine->mempool, tokens[0]); |
|
1655 | 1655 |
if(!new->name) { |
1656 | 1656 |
mpool_free(engine->mempool, new); |
1657 | 1657 |
ret = CL_EMEM; |
... | ... |
@@ -416,7 +416,7 @@ static unsigned int lhdr(fmap_t *map, uint32_t loff,uint32_t zsize, unsigned int |
416 | 416 |
static unsigned int chdr(fmap_t *map, uint32_t coff, uint32_t zsize, unsigned int *fu, unsigned int fc, int *ret, cli_ctx *ctx, char *tmpd) { |
417 | 417 |
char name[256]; |
418 | 418 |
int last = 0; |
419 |
- int8_t *ch; |
|
419 |
+ uint8_t *ch; |
|
420 | 420 |
|
421 | 421 |
if(!(ch = fmap_need_off(map, coff, SIZEOF_CH)) || CH_magic != 0x02014b50) { |
422 | 422 |
if(ch) fmap_unneed_ptr(map, ch, SIZEOF_CH); |
... | ... |
@@ -333,5 +333,6 @@ Suite *test_bytecode_suite(void) |
333 | 333 |
tcase_add_test(tc_cli_arith, test_pdf_int); |
334 | 334 |
tcase_add_test(tc_cli_arith, test_bswap_int); |
335 | 335 |
tcase_add_test(tc_cli_arith, test_inflate_int); |
336 |
+ tcase_add_test(tc_cli_arith, test_retmagic_int); |
|
336 | 337 |
return s; |
337 | 338 |
} |
... | ... |
@@ -342,23 +342,6 @@ static uint8_t tv2[56] = { |
342 | 342 |
0x6d, 0x6e, 0x6f, 0x70, 0x6e, 0x6f, 0x70, 0x71 |
343 | 343 |
}; |
344 | 344 |
|
345 |
-static uint8_t tv3[112] = { |
|
346 |
- 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, |
|
347 |
- 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, |
|
348 |
- 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, |
|
349 |
- 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, |
|
350 |
- 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, |
|
351 |
- 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, |
|
352 |
- 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, |
|
353 |
- 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, |
|
354 |
- 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, |
|
355 |
- 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, |
|
356 |
- 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, |
|
357 |
- 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, |
|
358 |
- 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, |
|
359 |
- 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75 |
|
360 |
-}; |
|
361 |
- |
|
362 | 345 |
static uint8_t res256[3][SHA256_HASH_SIZE] = { |
363 | 346 |
{ 0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, |
364 | 347 |
0x5d, 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, |
... | ... |
@@ -110,11 +110,11 @@ START_TEST (test_ac_scanbuff) { |
110 | 110 |
fail_unless(ret == CL_SUCCESS, "cli_ac_initdata() failed"); |
111 | 111 |
|
112 | 112 |
for(i = 0; ac_testdata[i].data; i++) { |
113 |
- ret = cli_ac_scanbuff(ac_testdata[i].data, strlen(ac_testdata[i].data), &virname, NULL, NULL, root, &mdata, 0, 0, NULL, AC_SCAN_VIR, NULL); |
|
113 |
+ ret = cli_ac_scanbuff((const unsigned char*)ac_testdata[i].data, strlen(ac_testdata[i].data), &virname, NULL, NULL, root, &mdata, 0, 0, NULL, AC_SCAN_VIR, NULL); |
|
114 | 114 |
fail_unless_fmt(ret == CL_VIRUS, "cli_ac_scanbuff() failed for %s", ac_testdata[i].virname); |
115 | 115 |
fail_unless_fmt(!strncmp(virname, ac_testdata[i].virname, strlen(ac_testdata[i].virname)), "Dataset %u matched with %s", i, virname); |
116 | 116 |
|
117 |
- ret = cli_scanbuff(ac_testdata[i].data, strlen(ac_testdata[i].data), 0, &ctx, 0, NULL); |
|
117 |
+ ret = cli_scanbuff((const unsigned char*)ac_testdata[i].data, strlen(ac_testdata[i].data), 0, &ctx, 0, NULL); |
|
118 | 118 |
fail_unless_fmt(ret == CL_VIRUS, "cli_scanbuff() failed for %s", ac_testdata[i].virname); |
119 | 119 |
fail_unless_fmt(!strncmp(virname, ac_testdata[i].virname, strlen(ac_testdata[i].virname)), "Dataset %u matched with %s", i, virname); |
120 | 120 |
} |
... | ... |
@@ -145,7 +145,7 @@ START_TEST (test_bm_scanbuff) { |
145 | 145 |
ret = cli_parse_add(root, "Sig3", "babedead", 0, 0, "*", 0, NULL, 0); |
146 | 146 |
fail_unless(ret == CL_SUCCESS, "cli_parse_add() failed"); |
147 | 147 |
|
148 |
- ret = cli_bm_scanbuff("blah\xde\xad\xbe\xef", 12, &virname, NULL, root, 0, NULL, NULL); |
|
148 |
+ ret = cli_bm_scanbuff((const unsigned char*)"blah\xde\xad\xbe\xef", 12, &virname, NULL, root, 0, NULL, NULL); |
|
149 | 149 |
fail_unless(ret == CL_VIRUS, "cli_bm_scanbuff() failed"); |
150 | 150 |
fail_unless(!strncmp(virname, "Sig2", 4), "Incorrect signature matched in cli_bm_scanbuff()\n"); |
151 | 151 |
} |
... | ... |
@@ -380,7 +380,7 @@ static void do_phishing_test(const struct rtest *rtest) |
380 | 380 |
hrefs.tag = cli_malloc(sizeof(*hrefs.tag)); |
381 | 381 |
fail_unless(!!hrefs.tag, "cli_malloc"); |
382 | 382 |
hrefs.tag[0] = (unsigned char*)cli_strdup("href"); |
383 |
- hrefs.contents[0] = cli_strdup(rtest->displayurl); |
|
383 |
+ hrefs.contents[0] = (unsigned char*)cli_strdup(rtest->displayurl); |
|
384 | 384 |
|
385 | 385 |
ctx.engine = engine; |
386 | 386 |
ctx.virname = &virname; |