diff --git a/ChangeLog b/ChangeLog index 7e551e4e1..a9684d663 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Apr 13 16:17:35 EEST 2010 (edwin) +------------------------------------- + * clambc, clamd,clamdtop,libclamav,unit_tests: fix compiler warnings (bb #1872, + bb #1934, bb #1935) + Tue Apr 13 16:13:05 EEST 2010 (edwin) ------------------------------------- * libclamav/c++: allow building with gcc 3.4.6 (bb #1934). diff --git a/clambc/bcrun.c b/clambc/bcrun.c index 54585e098..d812844c9 100644 --- a/clambc/bcrun.c +++ b/clambc/bcrun.c @@ -237,7 +237,7 @@ int main(int argc, char *argv[]) const struct optstruct *opt; unsigned funcid=0, i; struct cli_all_bc bcs; - unsigned int fd = -1; + int fd = -1; unsigned tracelevel; opts = optparse(NULL, argc, argv, 1, OPT_CLAMBC, 0, NULL); diff --git a/clamd/clamukofs.c b/clamd/clamukofs.c index 0cdd45182..cb6202b54 100644 --- a/clamd/clamukofs.c +++ b/clamd/clamukofs.c @@ -82,7 +82,6 @@ static void *clamuko_scanth(void *arg) { struct thrarg *tharg = (struct thrarg *) arg; sigset_t sigset; - short int scan; unsigned int sizelimit = 0; struct stat sb; dazukofs_handle_t scan_hndl; diff --git a/clamd/others.h b/clamd/others.h index c16f61118..af1c4a96b 100644 --- a/clamd/others.h +++ b/clamd/others.h @@ -38,7 +38,7 @@ enum mode { }; struct fd_buf { - unsigned char *buffer; + char *buffer; size_t bufsize; size_t off; int fd; diff --git a/clamd/scanner.c b/clamd/scanner.c index 461cb4bea..dc5f68e36 100644 --- a/clamd/scanner.c +++ b/clamd/scanner.c @@ -77,7 +77,6 @@ int scan_callback(struct stat *sb, char *filename, const char *msg, enum cli_ftw const char *virname; int ret; int type = scandata->type; - const struct optstruct *opt; /* detect disconnected socket, * this should NOT detect half-shutdown sockets (SHUT_WR) */ diff --git a/clamd/server-th.c b/clamd/server-th.c index 8676ed218..126547e9e 100644 --- a/clamd/server-th.c +++ b/clamd/server-th.c @@ -79,7 +79,7 @@ static void scanner_thread(void *arg) sigset_t sigset; #endif int ret; - unsigned virus=0, errors = 0; + int virus=0, errors = 0; #ifndef _WIN32 /* ignore all signals */ @@ -251,7 +251,7 @@ static struct cl_engine *reload_db(struct cl_engine *engine, unsigned int dbopti */ static const char *get_cmd(struct fd_buf *buf, size_t off, size_t *len, char *term, int *oldstyle) { - unsigned char *pos; + char *pos; if (!buf->off || off >= buf->off) { *len = 0; return NULL; @@ -466,9 +466,9 @@ static void *acceptloop_th(void *arg) return NULL; } -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) +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) { - const unsigned char *cmd = NULL; + const char *cmd = NULL; int rc; size_t cmdlen; char term; @@ -1164,7 +1164,7 @@ int recvloop_th(int *socketds, unsigned nsockets, struct cl_engine *engine, unsi while (!error && buf->fd != -1 && buf->buffer && pos < buf->off && buf->mode != MODE_WAITANCILL) { client_conn_t conn; - const unsigned char *cmd = NULL; + const char *cmd = NULL; int rc; /* New data available to read on socket. */ diff --git a/clamd/session.c b/clamd/session.c index 8fa2f3d7c..5aa7ed909 100644 --- a/clamd/session.c +++ b/clamd/session.c @@ -326,6 +326,9 @@ int command(client_conn_t *conn, int *virus) conn->scanfd = -1; cli_unlink(conn->filename); return ret; + default: + logg("!Invalid command distpached: %d\n", conn->cmdtype); + return 1; } scandata.type = type; @@ -413,6 +416,10 @@ static int dispatch_command(client_conn_t *conn, enum commands cmd, const char * bulk = 0; /* just dispatch the command */ break; + default: + logg("!Invalid command dispatch: %d\n", cmd); + ret = -2; + break; } if (!dup_conn->group) bulk = 0; diff --git a/clamd/thrmgr.c b/clamd/thrmgr.c index 8c920e28d..b1c76141d 100644 --- a/clamd/thrmgr.c +++ b/clamd/thrmgr.c @@ -784,6 +784,8 @@ int thrmgr_group_finished(jobgroup_t *group, enum thrmgr_exit exitc) case EXIT_ERROR: group->exit_error++; break; + default: + break; } if (group->jobs) { if (!--group->jobs) { diff --git a/clamdtop/clamdtop.c b/clamdtop/clamdtop.c index 8001d63be..5ebdb2b08 100644 --- a/clamdtop/clamdtop.c +++ b/clamdtop/clamdtop.c @@ -1133,7 +1133,6 @@ static void setup_connections(int argc, char *argv[]) default_colors = 1; memset(&global, 0, sizeof(global)); if (!opts->filename || !opts->filename[0]) { - char *aargv[2]; const struct optstruct *opt; const char *clamd_conf = optget(opts, "config-file")->strarg; diff --git a/libclamav/bytecode.c b/libclamav/bytecode.c index 599b3360c..a2434d5ac 100644 --- a/libclamav/bytecode.c +++ b/libclamav/bytecode.c @@ -418,7 +418,7 @@ static inline operand_t readOperand(struct cli_bc_func *func, unsigned char *p, return v; } -static inline unsigned char *readData(const unsigned char *p, unsigned *off, unsigned len, char *ok, unsigned *datalen) +static inline char *readData(const unsigned char *p, unsigned *off, unsigned len, char *ok, unsigned *datalen) { unsigned char *dat, *q; unsigned l, newoff, i; @@ -458,13 +458,13 @@ static inline unsigned char *readData(const unsigned char *p, unsigned *off, uns } *off = newoff; *datalen = l; - return dat; + return (char*)dat; } static inline char *readString(const unsigned char *p, unsigned *off, unsigned len, char *ok) { unsigned stringlen; - char *str = (char*)readData(p, off, len, ok, &stringlen); + char *str = readData(p, off, len, ok, &stringlen); if (*ok && stringlen && str[stringlen-1] != '\0') { str[stringlen-1] = '\0'; 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 return CL_EMALFDB; } offset++; - *linelength = strtol(buffer+offset, &pos, 10); + *linelength = strtol((const char*)buffer+offset, &pos, 10); if (*pos != '\0') { cli_errmsg("Invalid number: %s\n", buffer+offset); return CL_EMALFDB; @@ -548,7 +548,7 @@ static int parseHeader(struct cli_bc *bc, unsigned char *buffer, unsigned *linel return CL_SUCCESS; } -static int parseLSig(struct cli_bc *bc, unsigned char *buffer) +static int parseLSig(struct cli_bc *bc, char *buffer) { const char *prefix; char *vnames, *vend = strchr(buffer, ';'); @@ -920,7 +920,7 @@ static int parseGlobals(struct cli_bc *bc, unsigned char *buffer) static int parseMD(struct cli_bc *bc, unsigned char *buffer) { - unsigned offset = 1, len = strlen(buffer); + unsigned offset = 1, len = strlen((const char*)buffer); unsigned numMD, i, b; char ok = 1; if (buffer[0] != 'D') @@ -1345,7 +1345,7 @@ int cli_bytecode_load(struct cli_bc *bc, FILE *f, struct cli_dbio *dbio, int tru row++; switch (state) { case PARSE_BC_LSIG: - rc = parseLSig(bc, (unsigned char*)buffer); + rc = parseLSig(bc, buffer); if (rc == CL_BREAK) /* skip */ { bc->state = bc_skip; free(buffer); diff --git a/libclamav/bytecode_api.c b/libclamav/bytecode_api.c index f71aef894..41f512c9b 100644 --- a/libclamav/bytecode_api.c +++ b/libclamav/bytecode_api.c @@ -120,15 +120,15 @@ uint32_t cli_bcapi_debug_print_uint(struct cli_bc_ctx *ctx, uint32_t a) * executing */ uint32_t cli_bcapi_setvirusname(struct cli_bc_ctx* ctx, const uint8_t *name, uint32_t len) { - ctx->virname = name; + ctx->virname = (const char*)name; return 0; } uint32_t cli_bcapi_disasm_x86(struct cli_bc_ctx *ctx, struct DISASM_RESULT *res, uint32_t len) { int n; - const char *buf; - const char* next; + const unsigned char *buf; + const unsigned char* next; if (!res || !ctx->fmap || ctx->off >= ctx->fmap->len) return -1; /* 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 ctx->trace(ctx, trace_param); } if (ctx->trace_val && name) - ctx->trace_val(ctx, name, value); + ctx->trace_val(ctx, (const char*)name, value); return 0; } @@ -283,7 +283,7 @@ uint32_t cli_bcapi_trace_ptr(struct cli_bc_ctx *ctx, const uint8_t* ptr, uint32_ uint32_t cli_bcapi_pe_rawaddr(struct cli_bc_ctx *ctx, uint32_t rva) { uint32_t ret; - int err = 0; + unsigned err = 0; const struct cli_pe_hook_data *pe = ctx->hooks.pedata; ret = cli_rawaddr(rva, ctx->sections, pe->nsections, &err, 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_ { char buf[4096]; fmap_t *map = ctx->fmap; - uint32_t off = ctx->off, newoff; + uint32_t off = ctx->off; int n; 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, int32_t cli_bcapi_extract_new(struct cli_bc_ctx *ctx, int32_t id) { cli_ctx *cctx; - int res; + int res = -1; cli_dbgmsg("previous tempfile had %u bytes\n", ctx->written); if (!ctx->written) return 0; @@ -453,7 +453,6 @@ int32_t cli_bcapi_extract_new(struct cli_bc_ctx *ctx, int32_t id) #define BUF 16 int32_t cli_bcapi_read_number(struct cli_bc_ctx *ctx, uint32_t radix) { - unsigned char number[16]; unsigned i; char *p; int32_t result; @@ -864,7 +863,7 @@ static struct bc_jsnorm *get_jsnorm(struct cli_bc_ctx *ctx, int32_t id) int32_t cli_bcapi_jsnorm_process(struct cli_bc_ctx *ctx, int32_t id) { unsigned avail; - char *in; + unsigned char *in; cli_ctx *cctx = ctx->ctx; struct bc_jsnorm *b = get_jsnorm(ctx, id); 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) if (cctx && cli_checklimits("bytecode js api", cctx, ctx->jsnormwritten + avail, 0, 0)) return -1; cli_bcapi_buffer_pipe_read_stopped(ctx, b->from, avail); - cli_js_process_buffer(b->state, in, avail); + cli_js_process_buffer(b->state, (char*)in, avail); return 0; } diff --git a/libclamav/bytecode_api.h b/libclamav/bytecode_api.h index 1fc2d5bcb..8a1022cf2 100644 --- a/libclamav/bytecode_api.h +++ b/libclamav/bytecode_api.h @@ -52,7 +52,7 @@ enum BytecodeKind { _BC_LAST_HOOK }; -enum { PE_INVALID_RVA = 0xFFFFFFFF }; +static const unsigned PE_INVALID_RVA = 0xFFFFFFFF; #ifdef __CLAMBC__ diff --git a/libclamav/bytecode_vm.c b/libclamav/bytecode_vm.c index 49e677796..abeebb612 100644 --- a/libclamav/bytecode_vm.c +++ b/libclamav/bytecode_vm.c @@ -395,7 +395,7 @@ static always_inline struct stack_entry *pop_stack(struct stack *stack, #define CHECK_OP(cond, msg) if((cond)) { cli_dbgmsg(msg); stop = CL_EBYTECODE; break;} -#define DEFINE_CASTOP(opc, OP) \ +#define DEFINE_SCASTOP(opc, OP) \ case opc*5: {\ uint8_t res;\ int8_t sres;\ @@ -431,6 +431,7 @@ static always_inline struct stack_entry *pop_stack(struct stack *stack, WRITE64(inst->dest, res);\ break;\ } +#define DEFINE_CASTOP(opc, OP) DEFINE_SCASTOP(opc, OP; (void)sres) #define DEFINE_OP(opc) \ case opc*5: /* fall-through */\ @@ -490,7 +491,7 @@ static inline int32_t ptr_diff32(int64_t ptr1, int64_t ptr2) int32_t ptrid1 = ptr1 >> 32; int32_t ptrid2 = ptr2 >> 32; if (ptrid1 != ptrid2) { - bcfail("difference of pointers not pointing to same object!", ptrid1, ptrid2, __FILE__, __LINE__); + (void)bcfail("difference of pointers not pointing to same object!", ptrid1, ptrid2, __FILE__, __LINE__); /* invalid diff */ return 0x40000000; } @@ -498,10 +499,9 @@ static inline int32_t ptr_diff32(int64_t ptr1, int64_t ptr2) } static inline int64_t ptr_register_stack(struct ptr_infos *infos, - unsigned char *values, + char *values, uint32_t off, uint32_t size) { - int16_t id; unsigned n = infos->nstacks + 1; struct ptr_info *sinfos = cli_realloc(infos->stack_infos, sizeof(*sinfos)*n); @@ -510,7 +510,7 @@ static inline int64_t ptr_register_stack(struct ptr_infos *infos, infos->stack_infos = sinfos; infos->nstacks = n; sinfos = &sinfos[n-1]; - sinfos->base = values + off; + sinfos->base = (uint8_t*)values + off; sinfos->size = size; return ptr_compose(-n, 0); } @@ -556,20 +556,20 @@ static inline void* ptr_torealptr(const struct ptr_infos *infos, int64_t ptr, int32_t ptrid = ptr >> 32; uint32_t ptroff = (uint32_t)ptr; if (UNLIKELY(!ptrid)) { - bcfail("nullptr", ptrid, 0, __FILE__, __LINE__); + (void)bcfail("nullptr", ptrid, 0, __FILE__, __LINE__); return NULL; } if (ptrid < 0) { ptrid = -ptrid-1; if (UNLIKELY(ptrid >= infos->nstacks)) { - bcfail("ptr", ptrid, infos->nstacks, __FILE__, __LINE__); + (void)bcfail("ptr", ptrid, infos->nstacks, __FILE__, __LINE__); return NULL; } info = &infos->stack_infos[ptrid]; } else { ptrid--; if (UNLIKELY(ptrid >= infos->nglobs)) { - bcfail("ptr", ptrid, infos->nglobs, __FILE__, __LINE__); + (void)bcfail("ptr", ptrid, infos->nglobs, __FILE__, __LINE__); return NULL; } info = &infos->glob_infos[ptrid]; @@ -580,9 +580,9 @@ static inline void* ptr_torealptr(const struct ptr_infos *infos, int64_t ptr, return info->base+ptroff; } - bcfail("ptr1", ptroff, info->size, __FILE__, __LINE__); - bcfail("ptr2", read_size, info->size, __FILE__, __LINE__); - bcfail("ptr3", ptroff+read_size, info->size, __FILE__, __LINE__); + (void)bcfail("ptr1", ptroff, info->size, __FILE__, __LINE__); + (void)bcfail("ptr2", read_size, info->size, __FILE__, __LINE__); + (void)bcfail("ptr3", ptroff+read_size, info->size, __FILE__, __LINE__); return NULL; } @@ -610,8 +610,9 @@ static unsigned globaltypesize(uint16_t id) s += globaltypesize(ty->containedTypes[i]); return s; } + default: + return 0; } - return 0; } 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 DEFINE_BINOP(OP_BC_OR, res = op0 | op1); DEFINE_BINOP(OP_BC_XOR, res = op0 ^ op1); - DEFINE_CASTOP(OP_BC_SEXT, + DEFINE_SCASTOP(OP_BC_SEXT, CHOOSE(READ1(sres, inst->u.cast.source); res = sres ? ~0ull : 0, READ8(sres, inst->u.cast.source); res=sres=SIGNEXT(sres, inst->u.cast.mask), 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 TRACE_API(api->name, inst->dest, inst->type, stack_depth); switch (api->kind) { case 0: { - int32_t a, b, r; + int32_t a, b; READ32(a, inst->u.ops.ops[0]); READ32(b, inst->u.ops.ops[1]); 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 } DEFINE_OP(OP_BC_MEMCPY) { int32_t arg3; - void *arg1, *arg2, *resp; + void *arg1, *arg2; int64_t res=0; 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 } DEFINE_OP(OP_BC_MEMMOVE) { int32_t arg3; - void *arg1, *arg2, *resp; + void *arg1, *arg2; int64_t res=0; READ32(arg3, inst->u.three[2]); diff --git a/libclamav/c++/ClamBCModule.h b/libclamav/c++/ClamBCModule.h index d9dd964da..cf8339b95 100644 --- a/libclamav/c++/ClamBCModule.h +++ b/libclamav/c++/ClamBCModule.h @@ -5,8 +5,6 @@ namespace llvm { class Pass; } namespace ClamBCModule { - static void stop(const char *msg, llvm::Function* F, llvm::Instruction* I) { - llvm::errs() << msg << "\n"; - } + void stop(const char *msg, llvm::Function* F, llvm::Instruction* I); } llvm::Pass *createClamBCRTChecks(); diff --git a/libclamav/c++/bytecode2llvm.cpp b/libclamav/c++/bytecode2llvm.cpp index 3b38259a3..07e9f9c41 100644 --- a/libclamav/c++/bytecode2llvm.cpp +++ b/libclamav/c++/bytecode2llvm.cpp @@ -1999,8 +1999,10 @@ void cli_bytecode_debug_printsrc(const struct cli_bc_ctx *ctx) return; } assert(ctx->line < lines->linev.size()); - SMDiagnostic diag(ctx->file, ctx->line ? ctx->line : -1, - ctx->col ? ctx->col-1 : -1, + + int line = (int)ctx->line ? (int)ctx->line : -1; + int col = (int)ctx->col ? (int)ctx->col : -1; + SMDiagnostic diag(ctx->file, line, col, "", std::string(lines->linev[ctx->line-1], lines->linev[ctx->line]-1)); diag.Print("[trace]", errs()); } @@ -2010,3 +2012,10 @@ void cli_bytecode_printversion() { cl::PrintVersionMessage(); } + +namespace ClamBCModule { +void stop(const char *msg, llvm::Function* F, llvm::Instruction* I) +{ + llvm::errs() << msg << "\n"; +} +} diff --git a/libclamav/c++/llvm/lib/CodeGen/LiveInterval.cpp b/libclamav/c++/llvm/lib/CodeGen/LiveInterval.cpp index 7af25dd7e..465b30692 100644 --- a/libclamav/c++/llvm/lib/CodeGen/LiveInterval.cpp +++ b/libclamav/c++/llvm/lib/CodeGen/LiveInterval.cpp @@ -303,7 +303,6 @@ void LiveInterval::removeRange(SlotIndex Start, SlotIndex End, // otherwise mark it as ~1U so it can be nuked later. if (ValNo->id == getNumValNums()-1) { do { - VNInfo *VNI = valnos.back(); valnos.pop_back(); } while (!valnos.empty() && valnos.back()->isUnused()); } else { @@ -350,7 +349,6 @@ void LiveInterval::removeValNo(VNInfo *ValNo) { // otherwise mark it as ~1U so it can be nuked later. if (ValNo->id == getNumValNums()-1) { do { - VNInfo *VNI = valnos.back(); valnos.pop_back(); } while (!valnos.empty() && valnos.back()->isUnused()); } else { @@ -577,7 +575,6 @@ void LiveInterval::MergeValueInAsValue( // mark it as ~1U so it can be nuked later. if (V1->id == getNumValNums()-1) { do { - VNInfo *VNI = valnos.back(); valnos.pop_back(); } while (!valnos.empty() && valnos.back()->isUnused()); } else { @@ -745,7 +742,6 @@ VNInfo* LiveInterval::MergeValueNumberInto(VNInfo *V1, VNInfo *V2) { // ~1U so it can be nuked later. if (V1->id == getNumValNums()-1) { do { - VNInfo *VNI = valnos.back(); valnos.pop_back(); } while (valnos.back()->isUnused()); } else { diff --git a/libclamav/filtering.c b/libclamav/filtering.c index 9300172d0..ee3f11b08 100644 --- a/libclamav/filtering.c +++ b/libclamav/filtering.c @@ -412,7 +412,7 @@ int filter_add_acpatt(struct filter *m, const struct cli_ac_patt *pat) int32_t best_score = -0x7fffffff; unsigned best_score_i = 0; unsigned best_score_len = 0; - struct char_spec *spec0, *spec1; + struct char_spec *spec0 = NULL, *spec1 = NULL; struct choice choices[MAX_CHOICES]; unsigned choices_cnt = 0; @@ -641,7 +641,8 @@ int filter_add_acpatt(struct filter *m, const struct cli_ac_patt *pat) } j = best_score_len - 2; - for (k0=spec0->start;k0 <= spec0->end;k0 += spec0->step) { + if (spec0 && spec1) { + for (k0=spec0->start;k0 <= spec0->end;k0 += spec0->step) { for (k1=spec1->start;k1 <= spec1->end;k1 += spec1->step) { unsigned char c0 = spec_ith_char(spec0, k0); 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) } filter_set_end(m, j, c0 | (c1<<8)); } + } } return j+2; } @@ -699,7 +701,6 @@ __hot__ int filter_search_ext(const struct filter *m, const unsigned char *data, uint8_t state = ~0; const uint8_t *B = m->B; const uint8_t *End = m->end; - uint8_t shortest, longest=0; if (len < 2) return -1; /* look for first match */ diff --git a/libclamav/ishield.c b/libclamav/ishield.c index bbdec1046..3987a9f47 100644 --- a/libclamav/ishield.c +++ b/libclamav/ishield.c @@ -480,7 +480,6 @@ static int is_parse_hdr(cli_ctx *ctx, struct IS_CABSTUFF *c) { int ret = CL_BREAK; char hash[33], *hdr; fmap_t *map = *ctx->fmap; - size_t mp_hdrsz; struct IS_HDR *h1; struct IS_OBJECTS *objs; diff --git a/libclamav/libclamav.map b/libclamav/libclamav.map index 643a28333..c2150e14c 100644 --- a/libclamav/libclamav.map +++ b/libclamav/libclamav.map @@ -28,8 +28,6 @@ CLAMAV_PUBLIC { cl_statinidir; cl_countsigs; cl_strerror; - local: - *; }; CLAMAV_PRIVATE { global: diff --git a/libclamav/matcher-ac.c b/libclamav/matcher-ac.c index e495b9591..78b2842c5 100644 --- a/libclamav/matcher-ac.c +++ b/libclamav/matcher-ac.c @@ -1618,7 +1618,7 @@ int cli_ac_addsig(struct cli_matcher *root, const char *virname, const char *hex break; } - if(!(c = cli_mpool_hex2str(root->mempool, h))) { + if(!(c = (char*)cli_mpool_hex2str(root->mempool, h))) { free(h); error = CL_EMALFDB; break; diff --git a/libclamav/mpool.c b/libclamav/mpool.c index 5388f8d5e..08f6c0d49 100644 --- a/libclamav/mpool.c +++ b/libclamav/mpool.c @@ -501,7 +501,7 @@ unsigned char *cli_mpool_hex2str(mpool_t *mp, const char *hex) { } str = mpool_malloc(mp, (len/2) + 1); - if (cli_hex2str_to(hex, str, len) == -1) { + if (cli_hex2str_to(hex, (char*)str, len) == -1) { mpool_free(mp, str); return NULL; } diff --git a/libclamav/pe.c b/libclamav/pe.c index 8a3c981e0..35c45d6bf 100644 --- a/libclamav/pe.c +++ b/libclamav/pe.c @@ -511,7 +511,7 @@ int cli_scanpe(cli_ctx *ctx, icon_groupset *iconset) char *src = NULL, *dest = NULL; int ndesc, ret = CL_CLEAN, upack = 0, native=0; size_t fsize; - uint32_t valign, falign, hdr_size, j, offset; + uint32_t valign, falign, hdr_size, j; struct cli_exe_section *exe_sections; struct cli_matcher *md5_sect; char timestr[32]; @@ -2571,11 +2571,11 @@ int cli_peheader(fmap_t *map, struct cli_exe_info *peinfo) char *k, *v, *s; /* FIXME: skip too long strings */ - k = cli_utf16toascii(vptr + 6, s_key_sz); + k = cli_utf16toascii((const char*)vptr + 6, s_key_sz); if(k) { - v = cli_utf16toascii(vptr + s_key_sz + 6, s_val_sz); + v = cli_utf16toascii((const char*)vptr + s_key_sz + 6, s_val_sz); if(v) { - s = cli_str2hex(vptr + 6, s_key_sz + s_val_sz - 6); + s = cli_str2hex((const char*)vptr + 6, s_key_sz + s_val_sz - 6); if(s) { cli_dbgmsg("VersionInfo (%x): '%s'='%s' - VI:%s\n", (uint32_t)(vptr - baseptr + 6), k, v, s); free(s); diff --git a/libclamav/pe_icons.c b/libclamav/pe_icons.c index ae27cc9e1..39a714f05 100644 --- a/libclamav/pe_icons.c +++ b/libclamav/pe_icons.c @@ -563,6 +563,7 @@ static void lab(double r, double g, double b, double *L, double *A, double *B) { *B = 200.0f * (y - z); } +#ifndef USE_FLOATS static void lab2(uint32_t r, uint32_t g, uint32_t b, int32_t *L, int32_t *A, int32_t *B) { uint32_t xx,yy,zz; @@ -591,6 +592,7 @@ static void lab2(uint32_t r, uint32_t g, uint32_t b, int32_t *L, int32_t *A, int *A = 500/4*(xx - yy); *B = 200/4*(yy - zz);/* /4 to avoid overflow */ } +#endif static double labdiff(unsigned int rgb) { unsigned int r, g, b; @@ -606,6 +608,7 @@ static double labdiff(unsigned int rgb) { return sqrt(pow(L1 - L2, 2.0f) + pow(A1 - A2, 2.0f) + pow(B1 - B2, 2.0f)); } +#ifndef USE_FLOATS static uint32_t labdiff2(unsigned int b) { unsigned int r2, g2, b2; int32_t L1, A1, B1, L2, A2, B2; @@ -629,6 +632,7 @@ static uint32_t labdiff2(unsigned int b) { ld += ad + bd; return ((uint32_t)(sqrt(ld/1024.0)))>>17; } +#endif static void makebmp(const char *step, const char *tempd, int w, int h, void *data) { 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_ struct icomtr metrics; unsigned char *rawimage; const char *tempd; - uint32_t *palette = NULL, *imagedata, *imagedata2; + uint32_t *palette = NULL, *imagedata; unsigned int scanlinesz, andlinesz; unsigned int width, height, depth, x, y; unsigned int err, scalemode = 2, enginesize; diff --git a/libclamav/readdb.c b/libclamav/readdb.c index f1d00f5da..e7534ad69 100644 --- a/libclamav/readdb.c +++ b/libclamav/readdb.c @@ -1651,7 +1651,7 @@ static int cli_loadinfo(FILE *fs, struct cl_engine *engine, unsigned int options ret = CL_EMEM; break; } - new->name = (unsigned char *) cli_mpool_strdup(engine->mempool, tokens[0]); + new->name = cli_mpool_strdup(engine->mempool, tokens[0]); if(!new->name) { mpool_free(engine->mempool, new); ret = CL_EMEM; diff --git a/libclamav/unzip.c b/libclamav/unzip.c index da40fcc57..0b3ce8437 100644 --- a/libclamav/unzip.c +++ b/libclamav/unzip.c @@ -416,7 +416,7 @@ static unsigned int lhdr(fmap_t *map, uint32_t loff,uint32_t zsize, unsigned int 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) { char name[256]; int last = 0; - int8_t *ch; + uint8_t *ch; if(!(ch = fmap_need_off(map, coff, SIZEOF_CH)) || CH_magic != 0x02014b50) { if(ch) fmap_unneed_ptr(map, ch, SIZEOF_CH); diff --git a/unit_tests/check_bytecode.c b/unit_tests/check_bytecode.c index e33093eb7..d81d3c025 100644 --- a/unit_tests/check_bytecode.c +++ b/unit_tests/check_bytecode.c @@ -333,5 +333,6 @@ Suite *test_bytecode_suite(void) tcase_add_test(tc_cli_arith, test_pdf_int); tcase_add_test(tc_cli_arith, test_bswap_int); tcase_add_test(tc_cli_arith, test_inflate_int); + tcase_add_test(tc_cli_arith, test_retmagic_int); return s; } diff --git a/unit_tests/check_clamav.c b/unit_tests/check_clamav.c index b459a1ed5..55e9341f8 100644 --- a/unit_tests/check_clamav.c +++ b/unit_tests/check_clamav.c @@ -342,23 +342,6 @@ static uint8_t tv2[56] = { 0x6d, 0x6e, 0x6f, 0x70, 0x6e, 0x6f, 0x70, 0x71 }; -static uint8_t tv3[112] = { - 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, - 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, - 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, - 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, - 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, - 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, - 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, - 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, - 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, - 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, - 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, - 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, - 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75 -}; - static uint8_t res256[3][SHA256_HASH_SIZE] = { { 0xba, 0x78, 0x16, 0xbf, 0x8f, 0x01, 0xcf, 0xea, 0x41, 0x41, 0x40, 0xde, 0x5d, 0xae, 0x22, 0x23, 0xb0, 0x03, 0x61, 0xa3, 0x96, 0x17, 0x7a, 0x9c, diff --git a/unit_tests/check_matchers.c b/unit_tests/check_matchers.c index 4ccef211a..517517940 100644 --- a/unit_tests/check_matchers.c +++ b/unit_tests/check_matchers.c @@ -110,11 +110,11 @@ START_TEST (test_ac_scanbuff) { fail_unless(ret == CL_SUCCESS, "cli_ac_initdata() failed"); for(i = 0; ac_testdata[i].data; i++) { - 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); + 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); fail_unless_fmt(ret == CL_VIRUS, "cli_ac_scanbuff() failed for %s", ac_testdata[i].virname); fail_unless_fmt(!strncmp(virname, ac_testdata[i].virname, strlen(ac_testdata[i].virname)), "Dataset %u matched with %s", i, virname); - ret = cli_scanbuff(ac_testdata[i].data, strlen(ac_testdata[i].data), 0, &ctx, 0, NULL); + ret = cli_scanbuff((const unsigned char*)ac_testdata[i].data, strlen(ac_testdata[i].data), 0, &ctx, 0, NULL); fail_unless_fmt(ret == CL_VIRUS, "cli_scanbuff() failed for %s", ac_testdata[i].virname); fail_unless_fmt(!strncmp(virname, ac_testdata[i].virname, strlen(ac_testdata[i].virname)), "Dataset %u matched with %s", i, virname); } @@ -145,7 +145,7 @@ START_TEST (test_bm_scanbuff) { ret = cli_parse_add(root, "Sig3", "babedead", 0, 0, "*", 0, NULL, 0); fail_unless(ret == CL_SUCCESS, "cli_parse_add() failed"); - ret = cli_bm_scanbuff("blah\xde\xad\xbe\xef", 12, &virname, NULL, root, 0, NULL, NULL); + ret = cli_bm_scanbuff((const unsigned char*)"blah\xde\xad\xbe\xef", 12, &virname, NULL, root, 0, NULL, NULL); fail_unless(ret == CL_VIRUS, "cli_bm_scanbuff() failed"); fail_unless(!strncmp(virname, "Sig2", 4), "Incorrect signature matched in cli_bm_scanbuff()\n"); } diff --git a/unit_tests/check_regex.c b/unit_tests/check_regex.c index 06cb6cd29..0e1a4c1e5 100644 --- a/unit_tests/check_regex.c +++ b/unit_tests/check_regex.c @@ -380,7 +380,7 @@ static void do_phishing_test(const struct rtest *rtest) hrefs.tag = cli_malloc(sizeof(*hrefs.tag)); fail_unless(!!hrefs.tag, "cli_malloc"); hrefs.tag[0] = (unsigned char*)cli_strdup("href"); - hrefs.contents[0] = cli_strdup(rtest->displayurl); + hrefs.contents[0] = (unsigned char*)cli_strdup(rtest->displayurl); ctx.engine = engine; ctx.virname = &virname; diff --git a/unit_tests/check_str.c b/unit_tests/check_str.c index 60ed2ae9d..10ef5ac96 100644 --- a/unit_tests/check_str.c +++ b/unit_tests/check_str.c @@ -167,7 +167,7 @@ END_TEST #ifdef CHECK_HAVE_LOOPS static struct base64lines { const char *line; - const unsigned char *decoded; + const char *decoded; unsigned int len; } base64tests[] = { {"", "", 0},