Silence a bunch of compiler warnings in libclamav

This commit is contained in:
Shawn Webb 2014-07-10 18:11:49 -04:00
parent 61985b7b1f
commit cd94be7a52
79 changed files with 542 additions and 555 deletions

View file

@ -22,10 +22,11 @@ int g_allocCount = 0;
int g_allocCountTemp = 0;
#endif
#include "clamav.h"
void *SzAlloc(void *p, size_t size)
{
p = p;
UNUSEDPARAM(p);
if (size == 0)
return 0;
#ifdef _SZ_ALLOC_DEBUG
@ -37,7 +38,7 @@ void *SzAlloc(void *p, size_t size)
void SzFree(void *p, void *address)
{
p = p;
UNUSEDPARAM(p);
#ifdef _SZ_ALLOC_DEBUG
if (address != 0)
{
@ -50,7 +51,7 @@ void SzFree(void *p, void *address)
void *SzAllocTemp(void *p, size_t size)
{
p = p;
UNUSEDPARAM(p);
if (size == 0)
return 0;
#ifdef _SZ_ALLOC_DEBUG
@ -65,7 +66,7 @@ void *SzAllocTemp(void *p, size_t size)
void SzFreeTemp(void *p, void *address)
{
p = p;
UNUSEDPARAM(p);
#ifdef _SZ_ALLOC_DEBUG
if (address != 0)
{

View file

@ -19,6 +19,9 @@ Byte k7zSignature[k7zSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C};
#define NUM_FOLDER_CODERS_MAX 32
#define NUM_CODER_STREAMS_MAX 32
void SzFolder_Free(CSzFolder *p, ISzAlloc *alloc);
int SzFolder_FindBindPairForOutStream(CSzFolder *p, UInt32 outStreamIndex);
void SzCoderInfo_Init(CSzCoderInfo *p)
{
Buf_Init(&p->Props);

View file

@ -115,6 +115,8 @@ StopCompilingDueBUG
#define LZMA_DIC_MIN (1 << 12)
void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState);
/* First LZMA-symbol is always decoded.
And it decodes new LZMA-symbols while (buf < bufLimit), but "buf" is without last normalization
Out:

View file

@ -68,7 +68,7 @@ void XzCheck_Update(CXzCheck *p, const void *data, size_t size)
case XZ_CHECK_CRC64: p->crc64 = Crc64Update(p->crc64, data, size); break;
case XZ_CHECK_SHA256:
if ((p->sha))
cl_update_hash(p->sha, (const Byte *)data, size);
cl_update_hash(p->sha, (void *)data, size);
break;
}
}

View file

@ -33,6 +33,11 @@
#define CODER_BUF_SIZE (1 << 17)
void BraState_Free(void *pp, ISzAlloc *alloc);
SRes BraState_SetProps(void *pp, const Byte *props, size_t propSize, ISzAlloc *alloc);
void BraState_Init(void *pp);
SRes BraState_SetFromMethod(IStateCoder *p, UInt64 id, ISzAlloc *alloc);
unsigned Xz_ReadVarInt(const Byte *p, size_t maxSize, UInt64 *value)
{
int i, limit;
@ -77,7 +82,7 @@ void BraState_Free(void *pp, ISzAlloc *alloc)
SRes BraState_SetProps(void *pp, const Byte *props, size_t propSize, ISzAlloc *alloc)
{
CBraState *p = ((CBraState *)pp);
alloc = alloc;
UNUSEDPARAM(alloc);
p->encodeMode = 0;
p->ip = 0;
if (p->methodId == XZ_ID_Delta)
@ -133,9 +138,9 @@ static SRes BraState_Code(void *pp, Byte *dest, SizeT *destLen, const Byte *src,
CBraState *p = ((CBraState *)pp);
SizeT destLenOrig = *destLen;
SizeT srcLenOrig = *srcLen;
UNUSEDPARAM(finishMode);
*destLen = 0;
*srcLen = 0;
finishMode = finishMode;
*wasFinished = 0;
while (destLenOrig > 0)
{
@ -300,9 +305,9 @@ static SRes Lzma2State_Code(void *pp, Byte *dest, SizeT *destLen, const Byte *sr
int srcWasFinished, ECoderFinishMode finishMode, int *wasFinished)
{
ELzmaStatus status;
UNUSEDPARAM(srcWasFinished);
/* ELzmaFinishMode fm = (finishMode == LZMA_FINISH_ANY) ? LZMA_FINISH_ANY : LZMA_FINISH_END; */
SRes res = Lzma2Dec_DecodeToBuf((CLzma2Dec *)pp, dest, destLen, src, srcLen, finishMode, &status);
srcWasFinished = srcWasFinished;
*wasFinished = (status == LZMA_STATUS_FINISHED_WITH_MARK);
return res;
}
@ -785,7 +790,7 @@ SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen,
srcRem = (SizeT)cur;
p->crc = CrcUpdate(p->crc, src, srcRem);
if ((p->sha))
cl_update_hash(p->sha, src, srcRem);
cl_update_hash(p->sha, (void *)src, srcRem);
(*srcLen) += srcRem;
src += srcRem;
p->indexPos += srcRem;

View file

@ -146,7 +146,7 @@ int cli_7unz (cli_ctx *ctx, size_t offset) {
}
name = (char *)utf16name;
for(j=0; j<newnamelen; j++) /* FIXME */
for(j=0; j<(size_t)newnamelen; j++) /* FIXME */
name[j] = utf16name[j];
name[j] = 0;
cli_dbgmsg("cli_7unz: extracting %s\n", name);
@ -177,7 +177,7 @@ int cli_7unz (cli_ctx *ctx, size_t offset) {
break;
cli_dbgmsg("cli_7unz: Saving to %s\n", name);
if(cli_writen(fd, outBuffer + offset, outSizeProcessed) != outSizeProcessed)
if((size_t)cli_writen(fd, outBuffer + offset, outSizeProcessed) != outSizeProcessed)
found = CL_EWRITE;
else
if ((found = cli_magic_scandesc(fd, ctx)) == CL_VIRUS)

View file

@ -52,7 +52,7 @@ int cli_scanapm(cli_ctx *ctx)
struct apm_driver_desc_map ddm;
struct apm_partition_info aptable, apentry;
int ret = CL_CLEAN, detection = CL_CLEAN, old_school = 0;
size_t sectorsize, maplen, partsize, sectorcheck;
size_t sectorsize, maplen, partsize;
off_t pos = 0, partoff = 0;
unsigned i;
uint32_t max_prtns = 0;

View file

@ -1044,7 +1044,7 @@ static int asn1_parse_mscat(fmap_t *map, size_t offset, unsigned int size, crtmg
break;
cl_update_hash(ctx, "\x31", 1);
cl_update_hash(ctx, attrs + 1, attrs_size - 1);
cl_update_hash(ctx, (void *)(attrs + 1), attrs_size - 1);
cl_finish_hash(ctx, sha1);
if(!fmap_need_ptr_once(map, asn1.content, asn1.size)) {
@ -1288,7 +1288,7 @@ static int asn1_parse_mscat(fmap_t *map, size_t offset, unsigned int size, crtmg
break;
cl_update_hash(ctx, "\x31", 1);
cl_update_hash(ctx, attrs + 1, attrs_size - 1);
cl_update_hash(ctx, (void *)(attrs + 1), attrs_size - 1);
cl_finish_hash(ctx, sha1);
} else {
ctx = cl_hash_init("md5");
@ -1296,7 +1296,7 @@ static int asn1_parse_mscat(fmap_t *map, size_t offset, unsigned int size, crtmg
break;
cl_update_hash(ctx, "\x31", 1);
cl_update_hash(ctx, attrs + 1, attrs_size - 1);
cl_update_hash(ctx, (void *)(attrs + 1), attrs_size - 1);
cl_finish_hash(ctx, sha1);
}

View file

@ -30,6 +30,7 @@
#include "others.h"
#include "clamav.h"
#include "fmap.h"
#include "binhex.h"
static const uint8_t hqxtbl[] = {

View file

@ -18,8 +18,6 @@
* MA 02110-1301, USA.
*/
static char const rcsid[] = "$Id: blob.c,v 1.64 2007/02/12 22:25:14 njh Exp $";
#if HAVE_CONFIG_H
#include "clamav-config.h"
#endif
@ -144,6 +142,8 @@ blobSetFilename(blob *b, const char *dir, const char *filename)
assert(b->magic == BLOBCLASS);
assert(filename != NULL);
UNUSEDPARAM(dir);
cli_dbgmsg("blobSetFilename: %s\n", filename);
if(b->name)
@ -474,6 +474,8 @@ fileblobDestroy(fileblob *fb)
void
fileblobPartialSet(fileblob *fb, const char *fullname, const char *arg)
{
UNUSEDPARAM(arg);
if(fb->b.name)
return;

View file

@ -363,6 +363,10 @@ int cli_bytecode_context_setparam_int(struct cli_bc_ctx *ctx, unsigned i, uint64
int cli_bytecode_context_setparam_ptr(struct cli_bc_ctx *ctx, unsigned i, void *data, unsigned datalen)
{
UNUSEDPARAM(ctx);
UNUSEDPARAM(i);
UNUSEDPARAM(data);
UNUSEDPARAM(datalen);
cli_errmsg("Pointer parameters are not implemented yet!\n");
return CL_EARG;
}
@ -2270,7 +2274,7 @@ static int cli_bytecode_prepare_interpreter(struct cli_bc *bc)
MAP(inst->u.three[1]);
MAP(inst->u.three[2]);
inst->u.three[0] = get_geptypesize(bc, inst->u.three[0]);
if (inst->u.three[0] == -1)
if ((int)(inst->u.three[0]) == -1)
ret = CL_EBYTECODE;
break;
case OP_BC_GEPZ:
@ -2644,7 +2648,7 @@ int cli_bytecode_prepare2(struct cl_engine *engine, struct cli_all_bc *bcs, unsi
rc = cli_bytecode_context_getresult_int(ctx);
/* check magic number, don't use 0 here because it is too easy for a
* buggy bytecode to return 0 */
if (rc != 0xda7aba5e) {
if ((unsigned int)rc != (unsigned int)0xda7aba5e) {
cli_warnmsg("Bytecode: selftest failed with code %08x. Please report to http://bugs.clamav.net\n",
rc);
if (engine->bytecode_mode == CL_BYTECODE_MODE_TEST)
@ -3012,7 +3016,7 @@ void cli_bytecode_describe(const struct cli_bc *bc)
unsigned len = strlen(cli_apicalls[i].name);
if (had)
printf(",");
if (len > cols) {
if (len > (unsigned int)cols) {
printf("\n\t");
cols = 72;
}

View file

@ -63,11 +63,13 @@
uint32_t cli_bcapi_test1(struct cli_bc_ctx *ctx, uint32_t a, uint32_t b)
{
UNUSEDPARAM(ctx);
return (a==0xf00dbeef && b==0xbeeff00d) ? 0x12345678 : 0x55;
}
uint32_t cli_bcapi_test2(struct cli_bc_ctx *ctx, uint32_t a)
{
UNUSEDPARAM(ctx);
return a == 0xf00d ? 0xd00f : 0x5555;
}
@ -131,6 +133,7 @@ int32_t cli_bcapi_seek(struct cli_bc_ctx* ctx, int32_t pos, uint32_t whence)
uint32_t cli_bcapi_debug_print_str(struct cli_bc_ctx *ctx, const uint8_t *str, uint32_t len)
{
UNUSEDPARAM(len);
cli_event_fastdata(EV, BCEV_DBG_STR, str, strlen((const char*)str));
cli_dbgmsg("bytecode debug: %s\n", str);
return 0;
@ -151,6 +154,7 @@ 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)
{
UNUSEDPARAM(len);
ctx->virname = (const char*)name;
return 0;
}
@ -160,7 +164,8 @@ uint32_t cli_bcapi_disasm_x86(struct cli_bc_ctx *ctx, struct DISASM_RESULT *res,
int n;
const unsigned char *buf;
const unsigned char* next;
if (!res || !ctx->fmap || ctx->off >= ctx->fmap->len) {
UNUSEDPARAM(len);
if (!res || !ctx->fmap || (size_t)(ctx->off) >= ctx->fmap->len) {
API_MISUSE();
return -1;
}
@ -255,6 +260,7 @@ uint32_t cli_bcapi_trace_scope(struct cli_bc_ctx *ctx, const uint8_t *scope, uin
uint32_t cli_bcapi_trace_directory(struct cli_bc_ctx *ctx, const uint8_t* dir, uint32_t dummy)
{
UNUSEDPARAM(dummy);
if (LIKELY(!ctx->trace_level))
return 0;
ctx->directory = (const char*)dir ? (const char*)dir : "";
@ -314,6 +320,7 @@ uint32_t cli_bcapi_trace_value(struct cli_bc_ctx *ctx, const uint8_t* name, uint
uint32_t cli_bcapi_trace_ptr(struct cli_bc_ctx *ctx, const uint8_t* ptr, uint32_t dummy)
{
UNUSEDPARAM(dummy);
if (LIKELY(ctx->trace_level < trace_val))
return 0;
if (ctx->trace_level&0x80) {
@ -395,7 +402,7 @@ int32_t cli_bcapi_file_find_limit(struct cli_bc_ctx *ctx , const uint8_t* data,
for (;;) {
const char *p;
int32_t readlen = sizeof(buf);
if (off + readlen > limit) {
if (off + readlen > (unsigned int)limit) {
readlen = limit - off;
if (readlen < 0)
return -1;
@ -463,6 +470,7 @@ int32_t cli_bcapi_fill_buffer(struct cli_bc_ctx *ctx, uint8_t* buf,
uint32_t pos, uint32_t fill)
{
int32_t res, remaining, tofill;
UNUSEDPARAM(fill);
if (!buf || !buflen || buflen > CLI_MAX_ALLOCATION || filled > buflen) {
cli_dbgmsg("fill_buffer1\n");
API_MISUSE();
@ -586,7 +594,7 @@ int32_t cli_bcapi_hashset_new(struct cli_bc_ctx *ctx )
static struct cli_hashset *get_hashset(struct cli_bc_ctx *ctx, int32_t id)
{
if (id < 0 || id >= ctx->nhashsets || !ctx->hashsets) {
if (id < 0 || (unsigned int)id >= ctx->nhashsets || !ctx->hashsets) {
API_MISUSE();
return NULL;
}
@ -629,7 +637,7 @@ int32_t cli_bcapi_hashset_done(struct cli_bc_ctx *ctx , int32_t id)
if (!s)
return -1;
cli_hashset_destroy(s);
if (id == ctx->nhashsets-1) {
if ((unsigned int)id == ctx->nhashsets-1) {
ctx->nhashsets--;
if (!ctx->nhashsets) {
free(ctx->hashsets);
@ -693,7 +701,7 @@ int32_t cli_bcapi_buffer_pipe_new_fromfile(struct cli_bc_ctx *ctx , uint32_t at)
static struct bc_buffer *get_buffer(struct cli_bc_ctx *ctx, int32_t id)
{
if (!ctx->buffers || id < 0 || id >= ctx->nbuffers) {
if (!ctx->buffers || id < 0 || (unsigned int)id >= ctx->nbuffers) {
cli_dbgmsg("bytecode api: invalid buffer id %u\n", id);
return NULL;
}
@ -839,7 +847,7 @@ int32_t cli_bcapi_inflate_init(struct cli_bc_ctx *ctx, int32_t from, int32_t to,
static struct bc_inflate *get_inflate(struct cli_bc_ctx *ctx, int32_t id)
{
if (id < 0 || id >= ctx->ninflates || !ctx->inflates)
if (id < 0 || (unsigned int)id >= ctx->ninflates || !ctx->inflates)
return NULL;
return &ctx->inflates[id];
}
@ -921,6 +929,7 @@ int32_t cli_bcapi_bytecode_rt_error(struct cli_bc_ctx *ctx , int32_t id)
{
int32_t line = id >> 8;
int32_t col = id&0xff;
UNUSEDPARAM(ctx);
cli_warnmsg("Bytecode runtime error at line %u, col %u\n", line, col);
return 0;
}
@ -963,7 +972,7 @@ int32_t cli_bcapi_jsnorm_init(struct cli_bc_ctx *ctx, int32_t from)
static struct bc_jsnorm *get_jsnorm(struct cli_bc_ctx *ctx, int32_t id)
{
if (id < 0 || id >= ctx->njsnorms || !ctx->jsnorms)
if (id < 0 || (unsigned int)id >= ctx->njsnorms || !ctx->jsnorms)
return NULL;
return &ctx->jsnorms[id];
}
@ -1013,6 +1022,7 @@ static inline double myround(double a)
int32_t cli_bcapi_ilog2(struct cli_bc_ctx *ctx, uint32_t a, uint32_t b)
{
double f;
UNUSEDPARAM(ctx);
if (!b)
return 0x7fffffff;
/* log(a/b) is -32..32, so 2^26*32=2^31 covers the entire range of int32 */
@ -1022,6 +1032,7 @@ int32_t cli_bcapi_ilog2(struct cli_bc_ctx *ctx, uint32_t a, uint32_t b)
int32_t cli_bcapi_ipow(struct cli_bc_ctx *ctx, int32_t a, int32_t b, int32_t c)
{
UNUSEDPARAM(ctx);
if (!a && b < 0)
return 0x7fffffff;
return (int32_t)myround(c*pow(a,b));
@ -1030,6 +1041,7 @@ int32_t cli_bcapi_ipow(struct cli_bc_ctx *ctx, int32_t a, int32_t b, int32_t c)
uint32_t cli_bcapi_iexp(struct cli_bc_ctx *ctx, int32_t a, int32_t b, int32_t c)
{
double f;
UNUSEDPARAM(ctx);
if (!b)
return 0x7fffffff;
f= c*exp((double)a/b);
@ -1039,6 +1051,7 @@ uint32_t cli_bcapi_iexp(struct cli_bc_ctx *ctx, int32_t a, int32_t b, int32_t c)
int32_t cli_bcapi_isin(struct cli_bc_ctx *ctx, int32_t a, int32_t b, int32_t c)
{
double f;
UNUSEDPARAM(ctx);
if (!b)
return 0x7fffffff;
f = c*sin((double)a/b);
@ -1048,6 +1061,7 @@ int32_t cli_bcapi_isin(struct cli_bc_ctx *ctx, int32_t a, int32_t b, int32_t c)
int32_t cli_bcapi_icos(struct cli_bc_ctx *ctx, int32_t a, int32_t b, int32_t c)
{
double f;
UNUSEDPARAM(ctx);
if (!b)
return 0x7fffffff;
f = c*cos((double)a/b);
@ -1074,6 +1088,8 @@ int32_t cli_bcapi_hex2ui(struct cli_bc_ctx *ctx, uint32_t ah, uint32_t bh)
{
char result = 0;
unsigned char in[2];
UNUSEDPARAM(ctx);
in[0] = ah;
in[1] = bh;
@ -1086,6 +1102,8 @@ int32_t cli_bcapi_atoi(struct cli_bc_ctx *ctx, const uint8_t* str, int32_t len)
{
int32_t number = 0;
const uint8_t *end = str + len;
UNUSEDPARAM(ctx);
while (isspace(*str) && str < end) str++;
if (str == end)
return -1;/* all spaces */
@ -1104,6 +1122,8 @@ int32_t cli_bcapi_atoi(struct cli_bc_ctx *ctx, const uint8_t* str, int32_t len)
uint32_t cli_bcapi_debug_print_str_start(struct cli_bc_ctx *ctx , const uint8_t* s, uint32_t len)
{
UNUSEDPARAM(ctx);
if (!s || len <= 0)
return -1;
cli_event_fastdata(EV, BCEV_DBG_STR, s, len);
@ -1113,6 +1133,8 @@ uint32_t cli_bcapi_debug_print_str_start(struct cli_bc_ctx *ctx , const uint8_t*
uint32_t cli_bcapi_debug_print_str_nonl(struct cli_bc_ctx *ctx , const uint8_t* s, uint32_t len)
{
UNUSEDPARAM(ctx);
if (!s || len <= 0)
return -1;
if (!cli_debug_flag)
@ -1123,14 +1145,16 @@ uint32_t cli_bcapi_debug_print_str_nonl(struct cli_bc_ctx *ctx , const uint8_t*
uint32_t cli_bcapi_entropy_buffer(struct cli_bc_ctx *ctx , uint8_t* s, int32_t len)
{
uint32_t probTable[256];
unsigned i;
unsigned int i;
double entropy = 0;
double log2 = log(2);
UNUSEDPARAM(ctx);
if (!s || len <= 0)
return -1;
memset(probTable, 0, sizeof(probTable));
for (i=0;i<len;i++) {
for (i=0;i<(unsigned int)len;i++) {
probTable[s[i]]++;
}
for (i=0;i<256;i++) {
@ -1162,7 +1186,7 @@ int32_t cli_bcapi_map_new(struct cli_bc_ctx *ctx, int32_t keysize, int32_t value
static struct cli_map *get_hashtab(struct cli_bc_ctx *ctx, int32_t id)
{
if (id < 0 || id >= ctx->nmaps || !ctx->maps)
if (id < 0 || (unsigned int)id >= ctx->nmaps || !ctx->maps)
return NULL;
return &ctx->maps[id];
}
@ -1223,7 +1247,7 @@ int32_t cli_bcapi_map_done(struct cli_bc_ctx *ctx , int32_t id)
if (!s)
return -1;
cli_map_delete(s);
if (id == ctx->nmaps-1) {
if ((unsigned int)id == ctx->nmaps-1) {
ctx->nmaps--;
if (!ctx->nmaps) {
free(ctx->maps);
@ -1239,11 +1263,13 @@ int32_t cli_bcapi_map_done(struct cli_bc_ctx *ctx , int32_t id)
uint32_t cli_bcapi_engine_functionality_level(struct cli_bc_ctx *ctx)
{
UNUSEDPARAM(ctx);
return cl_retflevel();
}
uint32_t cli_bcapi_engine_dconf_level(struct cli_bc_ctx *ctx)
{
UNUSEDPARAM(ctx);
return CL_FLEVEL_DCONF;
}
@ -1270,7 +1296,7 @@ int32_t cli_bcapi_extract_set_container(struct cli_bc_ctx *ctx, uint32_t ftype)
int32_t cli_bcapi_input_switch(struct cli_bc_ctx *ctx , int32_t extracted_file)
{
fmap_t *map;
if (ctx->extracted_file_input == extracted_file)
if (ctx->extracted_file_input == (unsigned int)extracted_file)
return 0;
if (!extracted_file) {
cli_dbgmsg("bytecode api: input switched back to main file\n");
@ -1304,6 +1330,7 @@ uint32_t cli_bcapi_get_environment(struct cli_bc_ctx *ctx , struct cli_environme
uint32_t cli_bcapi_disable_bytecode_if(struct cli_bc_ctx *ctx , const int8_t* reason, uint32_t len, uint32_t cond)
{
UNUSEDPARAM(len);
if (ctx->bc->kind != BC_STARTUP) {
cli_dbgmsg("Bytecode must be BC_STARTUP to call disable_bytecode_if\n");
return -1;
@ -1320,6 +1347,7 @@ uint32_t cli_bcapi_disable_bytecode_if(struct cli_bc_ctx *ctx , const int8_t* re
uint32_t cli_bcapi_disable_jit_if(struct cli_bc_ctx *ctx , const int8_t* reason, uint32_t len, uint32_t cond)
{
UNUSEDPARAM(len);
if (ctx->bc->kind != BC_STARTUP) {
cli_dbgmsg("Bytecode must be BC_STARTUP to call disable_jit_if\n");
return -1;
@ -1340,6 +1368,7 @@ int32_t cli_bcapi_version_compare(struct cli_bc_ctx *ctx , const uint8_t* lhs, u
{
unsigned i = 0, j = 0;
unsigned long li=0, ri=0;
UNUSEDPARAM(ctx);
do {
while (i < lhs_len && j < rhs_len && lhs[i] == rhs[j] &&
!isdigit(lhs[i]) && !isdigit(rhs[j])) {
@ -1451,11 +1480,11 @@ int32_t cli_bcapi_pdf_lookupobj(struct cli_bc_ctx *ctx , uint32_t objid)
uint32_t cli_bcapi_pdf_getobjsize(struct cli_bc_ctx *ctx , int32_t objidx)
{
if (!ctx->pdf_phase ||
objidx >= ctx->pdf_nobjs ||
(uint32_t)objidx >= ctx->pdf_nobjs ||
ctx->pdf_phase == PDF_PHASE_POSTDUMP /* map is obj itself, no access to pdf anymore */
)
return 0;
if (objidx + 1 == ctx->pdf_nobjs)
if ((uint32_t)(objidx + 1) == ctx->pdf_nobjs)
return ctx->pdf_size - ctx->pdf_objs[objidx].start;
return ctx->pdf_objs[objidx+1].start - ctx->pdf_objs[objidx].start - 4;
}
@ -1471,7 +1500,7 @@ const uint8_t* cli_bcapi_pdf_getobj(struct cli_bc_ctx *ctx , int32_t objidx, uin
int32_t cli_bcapi_pdf_getobjid(struct cli_bc_ctx *ctx , int32_t objidx)
{
if (!ctx->pdf_phase ||
objidx >= ctx->pdf_nobjs)
(uint32_t)objidx >= ctx->pdf_nobjs)
return -1;
return ctx->pdf_objs[objidx].id;
}
@ -1479,7 +1508,7 @@ int32_t cli_bcapi_pdf_getobjid(struct cli_bc_ctx *ctx , int32_t objidx)
int32_t cli_bcapi_pdf_getobjflags(struct cli_bc_ctx *ctx , int32_t objidx)
{
if (!ctx->pdf_phase ||
objidx >= ctx->pdf_nobjs)
(uint32_t)objidx >= ctx->pdf_nobjs)
return -1;
return ctx->pdf_objs[objidx].flags;
}
@ -1487,7 +1516,7 @@ int32_t cli_bcapi_pdf_getobjflags(struct cli_bc_ctx *ctx , int32_t objidx)
int32_t cli_bcapi_pdf_setobjflags(struct cli_bc_ctx *ctx , int32_t objidx, int32_t flags)
{
if (!ctx->pdf_phase ||
objidx >= ctx->pdf_nobjs)
(uint32_t)objidx >= ctx->pdf_nobjs)
return -1;
cli_dbgmsg("cli_pdf: bytecode setobjflags %08x -> %08x\n",
ctx->pdf_objs[objidx].flags,
@ -1499,7 +1528,7 @@ int32_t cli_bcapi_pdf_setobjflags(struct cli_bc_ctx *ctx , int32_t objidx, int32
int32_t cli_bcapi_pdf_get_offset(struct cli_bc_ctx *ctx , int32_t objidx)
{
if (!ctx->pdf_phase ||
objidx >= ctx->pdf_nobjs)
(uint32_t)objidx >= ctx->pdf_nobjs)
return -1;
return ctx->pdf_startoff + ctx->pdf_objs[objidx].start;
}
@ -1536,6 +1565,7 @@ int32_t cli_bcapi_json_is_active(struct cli_bc_ctx *ctx )
return 1;
}
#else
UNUSEDPARAM(ctx);
cli_dbgmsg("bytecode api: libjson is not enabled!\n");
#endif
return 0;
@ -1558,6 +1588,7 @@ static int32_t cli_bcapi_json_objs_init(struct cli_bc_ctx *ctx) {
return 0;
#else
UNUSEDPARAM(ctx);
return -1;
#endif
}
@ -1580,7 +1611,7 @@ int32_t cli_bcapi_json_get_object(struct cli_bc_ctx *ctx, const int8_t* name, in
INIT_JSON_OBJS(ctx);
jobjs = ((json_object **)(ctx->jsonobjs));
if (objid < 0 || objid >= ctx->njsonobjs) {
if (objid < 0 || (unsigned int)objid >= ctx->njsonobjs) {
cli_dbgmsg("bytecode api[json_get_object]: invalid json objid requested\n");
return -1;
}
@ -1619,6 +1650,10 @@ int32_t cli_bcapi_json_get_object(struct cli_bc_ctx *ctx, const int8_t* name, in
free(namep);
return n-1;
#else
UNUSEDPARAM(ctx);
UNUSEDPARAM(name);
UNUSEDPARAM(name_len);
UNUSEDPARAM(objid);
cli_dbgmsg("bytecode api: libjson is not enabled!\n");
return -1;
#endif
@ -1632,7 +1667,7 @@ int32_t cli_bcapi_json_get_type(struct cli_bc_ctx *ctx, int32_t objid)
INIT_JSON_OBJS(ctx);
jobjs = ((json_object **)(ctx->jsonobjs));
if (objid < 0 || objid >= ctx->njsonobjs) {
if (objid < 0 || (unsigned int)objid >= ctx->njsonobjs) {
cli_dbgmsg("bytecode api[json_get_type]: invalid json objid requested\n");
return -1;
}
@ -1658,6 +1693,8 @@ int32_t cli_bcapi_json_get_type(struct cli_bc_ctx *ctx, int32_t objid)
}
#else
UNUSEDPARAM(ctx);
UNUSEDPARAM(objid);
cli_dbgmsg("bytecode api: libjson is not enabled!\n");
#endif
return -1;
@ -1671,7 +1708,7 @@ int32_t cli_bcapi_json_get_array_length(struct cli_bc_ctx *ctx, int32_t objid)
INIT_JSON_OBJS(ctx);
jobjs = (json_object **)(ctx->jsonobjs);
if (objid < 0 || objid >= ctx->njsonobjs) {
if (objid < 0 || (unsigned int)objid >= ctx->njsonobjs) {
cli_dbgmsg("bytecode api[json_array_get_length]: invalid json objid requested\n");
return -1;
}
@ -1683,6 +1720,8 @@ int32_t cli_bcapi_json_get_array_length(struct cli_bc_ctx *ctx, int32_t objid)
return json_object_array_length(jobjs[objid]);
#else
UNUSEDPARAM(ctx);
UNUSEDPARAM(objid);
cli_dbgmsg("bytecode api: libjson is not enabled!\n");
return -1;
#endif
@ -1698,7 +1737,7 @@ int32_t cli_bcapi_json_get_array_idx(struct cli_bc_ctx *ctx, int32_t idx, int32_
INIT_JSON_OBJS(ctx);
jobjs = (json_object **)(ctx->jsonobjs);
if (objid < 0 || objid >= ctx->njsonobjs) {
if (objid < 0 || (unsigned int)objid >= ctx->njsonobjs) {
cli_dbgmsg("bytecode api[json_array_get_idx]: invalid json objid requested\n");
return -1;
}
@ -1736,6 +1775,9 @@ int32_t cli_bcapi_json_get_array_idx(struct cli_bc_ctx *ctx, int32_t idx, int32_
return 0;
#else
UNUSEDPARAM(ctx);
UNUSEDPARAM(idx);
UNUSEDPARAM(objid);
cli_dbgmsg("bytecode api: libjson is not enabled!\n");
return -1;
#endif
@ -1751,7 +1793,7 @@ int32_t cli_bcapi_json_get_string_length(struct cli_bc_ctx *ctx, int32_t objid)
INIT_JSON_OBJS(ctx);
jobjs = (json_object **)(ctx->jsonobjs);
if (objid < 0 || objid >= ctx->njsonobjs) {
if (objid < 0 || (unsigned int)objid >= ctx->njsonobjs) {
cli_dbgmsg("bytecode api[json_get_string_length]: invalid json objid requested\n");
return -1;
}
@ -1771,6 +1813,8 @@ int32_t cli_bcapi_json_get_string_length(struct cli_bc_ctx *ctx, int32_t objid)
return len;
#else
UNUSEDPARAM(ctx);
UNUSEDPARAM(objid);
cli_dbgmsg("bytecode api: libjson is not enabled!\n");
return -1;
#endif
@ -1786,7 +1830,7 @@ int32_t cli_bcapi_json_get_string(struct cli_bc_ctx *ctx, int8_t* str, int32_t s
INIT_JSON_OBJS(ctx);
jobjs = (json_object **)(ctx->jsonobjs);
if (objid < 0 || objid >= ctx->njsonobjs) {
if (objid < 0 || (unsigned int)objid >= ctx->njsonobjs) {
cli_dbgmsg("bytecode api[json_get_string]: invalid json objid requested\n");
return -1;
}
@ -1806,17 +1850,21 @@ int32_t cli_bcapi_json_get_string(struct cli_bc_ctx *ctx, int8_t* str, int32_t s
if (len+1 > str_len) {
/* limit on str-len */
strncpy(str, jstr, str_len-1);
strncpy((char *)str, jstr, str_len-1);
str[str_len-1] = '\0';
return str_len;
}
else {
/* limit on len+1 */
strncpy(str, jstr, len);
strncpy((char *)str, jstr, len);
str[len] = '\0';
return len+1;
}
#else
UNUSEDPARAM(ctx);
UNUSEDPARAM(str);
UNUSEDPARAM(str_len);
UNUSEDPARAM(objid);
cli_dbgmsg("bytecode api: libjson is not enabled!\n");
return -1;
#endif
@ -1829,7 +1877,7 @@ int32_t cli_bcapi_json_get_boolean(struct cli_bc_ctx *ctx, int32_t objid)
INIT_JSON_OBJS(ctx);
jobjs = (json_object **)(ctx->jsonobjs);
if (objid < 0 || objid >= ctx->njsonobjs) {
if (objid < 0 || (unsigned int)objid >= ctx->njsonobjs) {
cli_dbgmsg("bytecode api[json_get_boolean]: invalid json objid requested\n");
return -1;
}
@ -1837,6 +1885,8 @@ int32_t cli_bcapi_json_get_boolean(struct cli_bc_ctx *ctx, int32_t objid)
jobj = jobjs[objid];
return json_object_get_boolean(jobj);
#else
UNUSEDPARAM(ctx);
UNUSEDPARAM(objid);
cli_dbgmsg("bytecode api: libjson is not enabled!\n");
return 0;
#endif
@ -1849,7 +1899,7 @@ int32_t cli_bcapi_json_get_int(struct cli_bc_ctx *ctx, int32_t objid)
INIT_JSON_OBJS(ctx);
jobjs = (json_object **)(ctx->jsonobjs);
if (objid < 0 || objid >= ctx->njsonobjs) {
if (objid < 0 || (unsigned int)objid >= ctx->njsonobjs) {
cli_dbgmsg("bytecode api[json_get_int]: invalid json objid requested\n");
return -1;
}
@ -1857,6 +1907,8 @@ int32_t cli_bcapi_json_get_int(struct cli_bc_ctx *ctx, int32_t objid)
jobj = jobjs[objid];
return json_object_get_int(jobj);
#else
UNUSEDPARAM(ctx);
UNUSEDPARAM(objid);
cli_dbgmsg("bytecode api: libjson is not enabled!\n");
return 0;
#endif

View file

@ -47,21 +47,30 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
int cli_vm_execute_jit(const struct cli_all_bc *bcs, struct cli_bc_ctx *ctx, const struct cli_bc_func *func)
{
UNUSEDPARAM(bcs);
UNUSEDPARAM(ctx);
UNUSEDPARAM(func);
return CL_EBYTECODE;
}
int cli_bytecode_init_jit(struct cli_all_bc *allbc, unsigned dconfmask)
{
UNUSEDPARAM(allbc);
UNUSEDPARAM(dconfmask);
return CL_SUCCESS;
}
int cli_bytecode_done_jit(struct cli_all_bc *allbc, int partial)
{
UNUSEDPARAM(allbc);
UNUSEDPARAM(partial);
return CL_SUCCESS;
}
void cli_bytecode_debug(int argc, char **argv) {
/* Empty */
UNUSEDPARAM(argc);
UNUSEDPARAM(argv);
}
int bytecode_init(void)
@ -71,6 +80,7 @@ int bytecode_init(void)
void cli_bytecode_debug_printsrc(const struct cli_bc_ctx *ctx) {
/* Empty */
UNUSEDPARAM(ctx);
}
void cli_bytecode_printversion(void) {
printf("LLVM not compiled in\n");
@ -83,4 +93,5 @@ void cli_printcxxver()
void cli_detect_env_jit(struct cli_environment *env)
{
/* Empty */
UNUSEDPARAM(env);
}

View file

@ -555,13 +555,6 @@ static inline int64_t ptr_register_glob(struct ptr_infos *infos,
return ptr_register_glob_fixedid(infos, values, size, infos->nglobs+1);
}
static inline int64_t ptr_index(int64_t ptr, uint32_t off)
{
int32_t ptrid = ptr >> 32;
uint32_t ptroff = (uint32_t)ptr;
return ptr_compose(ptrid, ptroff+off);
}
static inline void* ptr_torealptr(const struct ptr_infos *infos, int64_t ptr,
uint32_t read_size)
{
@ -575,14 +568,14 @@ static inline void* ptr_torealptr(const struct ptr_infos *infos, int64_t ptr,
}
if (ptrid < 0) {
ptrid = -ptrid-1;
if (UNLIKELY(ptrid >= infos->nstacks)) {
if (UNLIKELY((const unsigned int)ptrid >= infos->nstacks)) {
(void)bcfail("ptr", ptrid, infos->nstacks, __FILE__, __LINE__);
return NULL;
}
info = &infos->stack_infos[ptrid];
} else {
ptrid--;
if (UNLIKELY(ptrid >= infos->nglobs)) {
if (UNLIKELY((const unsigned int)ptrid >= infos->nglobs)) {
(void)bcfail("ptr", ptrid, infos->nglobs, __FILE__, __LINE__);
return NULL;
}

View file

@ -932,7 +932,7 @@ int cache_check(unsigned char *hash, cli_ctx *ctx) {
todo -= readme;
at += readme;
if (cl_update_hash(hashctx, buf, readme)) {
if (cl_update_hash(hashctx, (void *)buf, readme)) {
cl_hash_destroy(hashctx);
cli_errmsg("cache_check: error reading while generating hash!\n");
return CL_EREAD;

View file

@ -670,7 +670,6 @@ int cli_chm_prepare_file(chm_metadata_t *metadata)
int cli_chm_open(const char *dirname, chm_metadata_t *metadata, cli_ctx *ctx)
{
STATBUF statbuf;
int retval;
cli_dbgmsg("in cli_chm_open\n");

View file

@ -69,7 +69,7 @@ static size_t base64_len(const char *data, size_t len)
void *cl_base64_decode(char *data, size_t len, void *obuf, size_t *olen)
{
BIO *bio, *b64;
void *buf, *ret;
void *buf;
buf = (obuf) ? obuf : malloc(base64_len(data, len)+1);
if (!(buf))

View file

@ -124,7 +124,7 @@ int cli_scancpio_old(cli_ctx *ctx)
if(hdr_old.namesize) {
hdr_namesize = EC16(hdr_old.namesize, conv);
namesize = MIN(sizeof(name), hdr_namesize);
if (fmap_readn(*ctx->fmap, &name, pos, namesize) != namesize) {
if ((uint32_t)fmap_readn(*ctx->fmap, &name, pos, namesize) != namesize) {
cli_dbgmsg("cli_scancpio_old: Can't read file name\n");
return CL_EFORMAT;
}
@ -202,7 +202,7 @@ int cli_scancpio_odc(cli_ctx *ctx)
}
if(hdr_namesize) {
namesize = MIN(sizeof(name), hdr_namesize);
if (fmap_readn(*ctx->fmap, &name, pos, namesize) != namesize) {
if ((uint32_t)fmap_readn(*ctx->fmap, &name, pos, namesize) != namesize) {
cli_dbgmsg("cli_scancpio_odc: Can't read file name\n");
return CL_EFORMAT;
}
@ -276,7 +276,7 @@ int cli_scancpio_newc(cli_ctx *ctx, int crc)
}
if(hdr_namesize) {
namesize = MIN(sizeof(name), hdr_namesize);
if (fmap_readn(*ctx->fmap, &name, pos, namesize) != namesize) {
if ((uint32_t)fmap_readn(*ctx->fmap, &name, pos, namesize) != namesize) {
cli_dbgmsg("cli_scancpio_newc: Can't read file name\n");
return CL_EFORMAT;
}

View file

@ -41,6 +41,7 @@ int cli_crt_init(cli_crt *x509) {
}
void cli_crt_clear(cli_crt *x509) {
UNUSEDPARAM(x509);
mp_clear_multi(&x509->n, &x509->e, &x509->sig, NULL);
}
@ -337,104 +338,8 @@ cli_crt *crtmgr_verify_pkcs7(crtmgr *m, const uint8_t *issuer, const uint8_t *se
return i;
}
/* DC=com, DC=microsoft, CN=Microsoft Root Certificate Authority */
static const uint8_t MSCA_SUBJECT[] = "\x11\x3b\xd8\x6b\xed\xde\xbc\xd4\xc5\xf1\x0a\xa0\x7a\xb2\x02\x6b\x98\x2f\x4b\x92";
static const uint8_t MSCA_MOD[] = "\
\x00\xf3\x5d\xfa\x80\x67\xd4\x5a\xa7\xa9\x0c\x2c\x90\x20\xd0\
\x35\x08\x3c\x75\x84\xcd\xb7\x07\x89\x9c\x89\xda\xde\xce\xc3\
\x60\xfa\x91\x68\x5a\x9e\x94\x71\x29\x18\x76\x7c\xc2\xe0\xc8\
\x25\x76\x94\x0e\x58\xfa\x04\x34\x36\xe6\xdf\xaf\xf7\x80\xba\
\xe9\x58\x0b\x2b\x93\xe5\x9d\x05\xe3\x77\x22\x91\xf7\x34\x64\
\x3c\x22\x91\x1d\x5e\xe1\x09\x90\xbc\x14\xfe\xfc\x75\x58\x19\
\xe1\x79\xb7\x07\x92\xa3\xae\x88\x59\x08\xd8\x9f\x07\xca\x03\
\x58\xfc\x68\x29\x6d\x32\xd7\xd2\xa8\xcb\x4b\xfc\xe1\x0b\x48\
\x32\x4f\xe6\xeb\xb8\xad\x4f\xe4\x5c\x6f\x13\x94\x99\xdb\x95\
\xd5\x75\xdb\xa8\x1a\xb7\x94\x91\xb4\x77\x5b\xf5\x48\x0c\x8f\
\x6a\x79\x7d\x14\x70\x04\x7d\x6d\xaf\x90\xf5\xda\x70\xd8\x47\
\xb7\xbf\x9b\x2f\x6c\xe7\x05\xb7\xe1\x11\x60\xac\x79\x91\x14\
\x7c\xc5\xd6\xa6\xe4\xe1\x7e\xd5\xc3\x7e\xe5\x92\xd2\x3c\x00\
\xb5\x36\x82\xde\x79\xe1\x6d\xf3\xb5\x6e\xf8\x9f\x33\xc9\xcb\
\x52\x7d\x73\x98\x36\xdb\x8b\xa1\x6b\xa2\x95\x97\x9b\xa3\xde\
\xc2\x4d\x26\xff\x06\x96\x67\x25\x06\xc8\xe7\xac\xe4\xee\x12\
\x33\x95\x31\x99\xc8\x35\x08\x4e\x34\xca\x79\x53\xd5\xb5\xbe\
\x63\x32\x59\x40\x36\xc0\xa5\x4e\x04\x4d\x3d\xdb\x5b\x07\x33\
\xe4\x58\xbf\xef\x3f\x53\x64\xd8\x42\x59\x35\x57\xfd\x0f\x45\
\x7c\x24\x04\x4d\x9e\xd6\x38\x74\x11\x97\x22\x90\xce\x68\x44\
\x74\x92\x6f\xd5\x4b\x6f\xb0\x86\xe3\xc7\x36\x42\xa0\xd0\xfc\
\xc1\xc0\x5a\xf9\xa3\x61\xb9\x30\x47\x71\x96\x0a\x16\xb0\x91\
\xc0\x42\x95\xef\x10\x7f\x28\x6a\xe3\x2a\x1f\xb1\xe4\xcd\x03\
\x3f\x77\x71\x04\xc7\x20\xfc\x49\x0f\x1d\x45\x88\xa4\xd7\xcb\
\x7e\x88\xad\x8e\x2d\xec\x45\xdb\xc4\x51\x04\xc9\x2a\xfc\xec\
\x86\x9e\x9a\x11\x97\x5b\xde\xce\x53\x88\xe6\xe2\xb7\xfd\xac\
\x95\xc2\x28\x40\xdb\xef\x04\x90\xdf\x81\x33\x39\xd9\xb2\x45\
\xa5\x23\x87\x06\xa5\x55\x89\x31\xbb\x06\x2d\x60\x0e\x41\x18\
\x7d\x1f\x2e\xb5\x97\xcb\x11\xeb\x15\xd5\x24\xa5\x94\xef\x15\
\x14\x89\xfd\x4b\x73\xfa\x32\x5b\xfc\xd1\x33\x00\xf9\x59\x62\
\x70\x07\x32\xea\x2e\xab\x40\x2d\x7b\xca\xdd\x21\x67\x1b\x30\
\x99\x8f\x16\xaa\x23\xa8\x41\xd1\xb0\x6e\x11\x9b\x36\xc4\xde\
\x40\x74\x9c\xe1\x58\x65\xc1\x60\x1e\x7a\x5b\x38\xc8\x8f\xbb\
\x04\x26\x7c\xd4\x16\x40\xe5\xb6\x6b\x6c\xaa\x86\xfd\x00\xbf\
\xce\xc1\x35";
static const uint8_t MSCA_EXP[] = "\x01\x00\x01";
/* OU=Copyright (c) 1997 Microsoft Corp., OU=Microsoft Corporation, CN=Microsoft Root Authority */
static const uint8_t MSA_SUBJECT[] = "\xad\xf7\x98\x77\x06\x5e\xf3\x05\xeb\x95\xb5\x6d\xbc\xa9\xe6\x3e\x9a\xb4\x0d\x3b";
static const uint8_t MSA_MOD[] = "\
\x00\xa9\x02\xbd\xc1\x70\xe6\x3b\xf2\x4e\x1b\x28\x9f\x97\x78\
\x5e\x30\xea\xa2\xa9\x8d\x25\x5f\xf8\xfe\x95\x4c\xa3\xb7\xfe\
\x9d\xa2\x20\x3e\x7c\x51\xa2\x9b\xa2\x8f\x60\x32\x6b\xd1\x42\
\x64\x79\xee\xac\x76\xc9\x54\xda\xf2\xeb\x9c\x86\x1c\x8f\x9f\
\x84\x66\xb3\xc5\x6b\x7a\x62\x23\xd6\x1d\x3c\xde\x0f\x01\x92\
\xe8\x96\xc4\xbf\x2d\x66\x9a\x9a\x68\x26\x99\xd0\x3a\x2c\xbf\
\x0c\xb5\x58\x26\xc1\x46\xe7\x0a\x3e\x38\x96\x2c\xa9\x28\x39\
\xa8\xec\x49\x83\x42\xe3\x84\x0f\xbb\x9a\x6c\x55\x61\xac\x82\
\x7c\xa1\x60\x2d\x77\x4c\xe9\x99\xb4\x64\x3b\x9a\x50\x1c\x31\
\x08\x24\x14\x9f\xa9\xe7\x91\x2b\x18\xe6\x3d\x98\x63\x14\x60\
\x58\x05\x65\x9f\x1d\x37\x52\x87\xf7\xa7\xef\x94\x02\xc6\x1b\
\xd3\xbf\x55\x45\xb3\x89\x80\xbf\x3a\xec\x54\x94\x4e\xae\xfd\
\xa7\x7a\x6d\x74\x4e\xaf\x18\xcc\x96\x09\x28\x21\x00\x57\x90\
\x60\x69\x37\xbb\x4b\x12\x07\x3c\x56\xff\x5b\xfb\xa4\x66\x0a\
\x08\xa6\xd2\x81\x56\x57\xef\xb6\x3b\x5e\x16\x81\x77\x04\xda\
\xf6\xbe\xae\x80\x95\xfe\xb0\xcd\x7f\xd6\xa7\x1a\x72\x5c\x3c\
\xca\xbc\xf0\x08\xa3\x22\x30\xb3\x06\x85\xc9\xb3\x20\x77\x13\
\x85\xdf";
static const uint8_t MSA_EXP[] = "\x01\x00\x01";
/* C=ZA, ST=Western Cape, L=Durbanville, O=Thawte, OU=Thawte Certification, CN=Thawte Timestamping CA */
static const uint8_t THAW_SUBJECT[] = "\x9a\x02\x27\x8e\x9c\xb1\x28\x76\xc4\x7a\xb0\xbc\x75\xdd\x69\x4e\x72\xd1\xb2\xbc";
static const uint8_t THAW_MOD[] = "\
\x00\xd6\x2b\x58\x78\x61\x45\x86\x53\xea\x34\x7b\x51\x9c\xed\
\xb0\xe6\x2e\x18\x0e\xfe\xe0\x5f\xa8\x27\xd3\xb4\xc9\xe0\x7c\
\x59\x4e\x16\x0e\x73\x54\x60\xc1\x7f\xf6\x9f\x2e\xe9\x3a\x85\
\x24\x15\x3c\xdb\x47\x04\x63\xc3\x9e\xc4\x94\x1a\x5a\xdf\x4c\
\x7a\xf3\xd9\x43\x1d\x3c\x10\x7a\x79\x25\xdb\x90\xfe\xf0\x51\
\xe7\x30\xd6\x41\x00\xfd\x9f\x28\xdf\x79\xbe\x94\xbb\x9d\xb6\
\x14\xe3\x23\x85\xd7\xa9\x41\xe0\x4c\xa4\x79\xb0\x2b\x1a\x8b\
\xf2\xf8\x3b\x8a\x3e\x45\xac\x71\x92\x00\xb4\x90\x41\x98\xfb\
\x5f\xed\xfa\xb7\x2e\x8a\xf8\x88\x37";
const uint8_t THAW_EXP[] = "\x01\x00\x01";
/* C=US, O=VeriSign, Inc., OU=Class 3 Public Primary Certification Authority */
static const uint8_t VER_SUBJECT[] = "\x29\xdb\xd4\xb8\x8f\x78\x5f\x33\x41\x92\x87\xe1\xaf\x46\x50\xe1\x77\xa4\x6f\xc0";
static const uint8_t VER_MOD[] = "\
\x00\xc9\x5c\x59\x9e\xf2\x1b\x8a\x01\x14\xb4\x10\xdf\x04\x40\
\xdb\xe3\x57\xaf\x6a\x45\x40\x8f\x84\x0c\x0b\xd1\x33\xd9\xd9\
\x11\xcf\xee\x02\x58\x1f\x25\xf7\x2a\xa8\x44\x05\xaa\xec\x03\
\x1f\x78\x7f\x9e\x93\xb9\x9a\x00\xaa\x23\x7d\xd6\xac\x85\xa2\
\x63\x45\xc7\x72\x27\xcc\xf4\x4c\xc6\x75\x71\xd2\x39\xef\x4f\
\x42\xf0\x75\xdf\x0a\x90\xc6\x8e\x20\x6f\x98\x0f\xf8\xac\x23\
\x5f\x70\x29\x36\xa4\xc9\x86\xe7\xb1\x9a\x20\xcb\x53\xa5\x85\
\xe7\x3d\xbe\x7d\x9a\xfe\x24\x45\x33\xdc\x76\x15\xed\x0f\xa2\
\x71\x64\x4c\x65\x2e\x81\x68\x45\xa7";
static const uint8_t VER_EXP[] = "\x01\x00\x01";
int crtmgr_add_roots(struct cl_engine *engine, crtmgr *m) {
cli_crt ca;
cli_crt *crt, *new_crt;
cli_crt *crt;
/*
* Certs are cached in engine->cmgr. Copy from there.
*/

View file

@ -164,7 +164,7 @@ unsigned char *cl_hash_data(char *alg, const void *buf, size_t len, unsigned cha
cur=0;
while (cur < len) {
size_t todo = MIN(EVP_MD_block_size(md), len-cur);
size_t todo = MIN((unsigned long)EVP_MD_block_size(md), (unsigned long)(len-cur));
if (!EVP_DigestUpdate(ctx, (void *)(((unsigned char *)buf)+cur), todo)) {
if (!(obuf))
free(ret);
@ -736,7 +736,7 @@ X509 *cl_get_x509_from_mem(void *data, unsigned int len)
int cl_validate_certificate_chain_ts_dir(char *tsdir, char *certpath)
{
char **authorities=NULL, **t, *fullpath;
char **authorities=NULL, **t;
size_t nauths = 0;
int res;
DIR *dp;
@ -964,7 +964,6 @@ struct tm *cl_ASN1_GetTimeT(ASN1_TIME *timeobj)
{
struct tm *t;
char* str;
size_t i = 0;
const char *fmt=NULL;
time_t localt;
#ifdef _WIN32
@ -1032,7 +1031,6 @@ X509_CRL *cl_load_crl(const char *file)
X509_CRL *x=NULL;
FILE *fp;
struct tm *tm;
time_t crltime;
if (!(file))
return NULL;

View file

@ -47,6 +47,7 @@
static void cli_untgz_cleanup(char *path, gzFile infile, FILE *outfile, int fdd)
{
UNUSEDPARAM(fdd);
cli_dbgmsg("in cli_untgz_cleanup()\n");
if (path != NULL)
free (path);
@ -180,6 +181,7 @@ static int cli_untgz(int fd, const char *destdir)
static void cli_tgzload_cleanup(int comp, struct cli_dbio *dbio, int fdd)
{
UNUSEDPARAM(fdd);
cli_dbgmsg("in cli_tgzload_cleanup()\n");
if(comp) {
gzclose(dbio->gzs);

View file

@ -342,6 +342,7 @@ int cli_dconf_load(FILE *fs, struct cl_engine *engine, unsigned int options, str
int ret = 0;
uint32_t val;
UNUSEDPARAM(options);
while(cli_dbgets(buffer, FILEBUFF, fs, dbio)) {
line++;

View file

@ -95,10 +95,10 @@ static int dmg_handle_mish(cli_ctx *, unsigned int, char *, uint64_t, struct dmg
int cli_scandmg(cli_ctx *ctx)
{
struct dmg_koly_block hdr;
int ret, namelen, ofd;
int ret;
size_t maplen, nread;
off_t pos = 0;
char *dirname, *tmpfile;
char *dirname;
const char *outdata;
unsigned int file = 0;
struct dmg_mish_with_stripes *mish_list = NULL, *mish_list_tail = NULL;
@ -255,7 +255,7 @@ int cli_scandmg(cli_ctx *ctx)
/* Reset state early, for continue cases */
stateDepth[DMG_FIND_KEY_DATA] = -1;
state--;
if (xmlStrcmp(nodeName, "data") != 0) {
if (xmlStrcmp(nodeName, (const xmlChar *)"data") != 0) {
cli_dbgmsg("cli_scandmg: Not blkx data element\n");
xmlFree(nodeName);
continue;
@ -316,7 +316,7 @@ int cli_scandmg(cli_ctx *ctx)
}
if ((state == DMG_FIND_KEY_DATA)
&& (depth > stateDepth[state-1])
&& (xmlStrcmp(nodeName, "key") == 0)) {
&& (xmlStrcmp(nodeName, (const xmlChar *)"key") == 0)) {
xmlChar * textValue;
dmg_parsemsg("read: Found key - checking for Data\n");
if (xmlTextReaderRead(reader) != 1) {
@ -334,7 +334,7 @@ int cli_scandmg(cli_ctx *ctx)
xmlFree(nodeName);
continue;
}
if (xmlStrcmp(textValue, "Data") == 0) {
if (xmlStrcmp(textValue, (const xmlChar *)"Data") == 0) {
dmg_parsemsg("read: Matched data\n");
stateDepth[DMG_FIND_KEY_DATA] = depth;
state++;
@ -346,12 +346,12 @@ int cli_scandmg(cli_ctx *ctx)
}
if ((state == DMG_FIND_BLKX_CONTAINER)
&& (depth == stateDepth[state-1])) {
if (xmlStrcmp(nodeName, "array") == 0) {
if (xmlStrcmp(nodeName, (const xmlChar *)"array") == 0) {
dmg_parsemsg("read: Found array blkx\n");
stateDepth[DMG_FIND_BLKX_CONTAINER] = depth;
state++;
}
else if (xmlStrcmp(nodeName, "dict") == 0) {
else if (xmlStrcmp(nodeName, (const xmlChar *)"dict") == 0) {
dmg_parsemsg("read: Found dict blkx\n");
stateDepth[DMG_FIND_BLKX_CONTAINER] = depth;
state++;
@ -364,7 +364,7 @@ int cli_scandmg(cli_ctx *ctx)
}
if ((state == DMG_FIND_KEY_BLKX)
&& (depth == stateDepth[state-1] + 1)
&& (xmlStrcmp(nodeName, "key") == 0)) {
&& (xmlStrcmp(nodeName, (const xmlChar *)"key") == 0)) {
xmlChar * textValue;
dmg_parsemsg("read: Found key - checking for blkx\n");
if (xmlTextReaderRead(reader) != 1) {
@ -382,7 +382,7 @@ int cli_scandmg(cli_ctx *ctx)
xmlFree(nodeName);
continue;
}
if (xmlStrcmp(textValue, "blkx") == 0) {
if (xmlStrcmp(textValue, (const xmlChar *)"blkx") == 0) {
cli_dbgmsg("cli_scandmg: Matched blkx\n");
stateDepth[DMG_FIND_KEY_BLKX] = depth;
state++;
@ -394,7 +394,7 @@ int cli_scandmg(cli_ctx *ctx)
}
if ((state == DMG_FIND_DICT_RESOURCE_FORK)
&& (depth == stateDepth[state-1])) {
if (xmlStrcmp(nodeName, "dict") == 0) {
if (xmlStrcmp(nodeName, (const xmlChar *)"dict") == 0) {
dmg_parsemsg("read: Found resource-fork dict\n");
stateDepth[DMG_FIND_DICT_RESOURCE_FORK] = depth;
state++;
@ -407,19 +407,19 @@ int cli_scandmg(cli_ctx *ctx)
}
if ((state == DMG_FIND_KEY_RESOURCE_FORK)
&& (depth == stateDepth[state-1] + 1)
&& (xmlStrcmp(nodeName, "key") == 0)) {
&& (xmlStrcmp(nodeName, (const xmlChar *)"key") == 0)) {
dmg_parsemsg("read: Found resource-fork key\n");
stateDepth[DMG_FIND_KEY_RESOURCE_FORK] = depth;
state++;
}
if ((state == DMG_FIND_BASE_DICT)
&& (depth == stateDepth[state-1] + 1)
&& (xmlStrcmp(nodeName, "dict") == 0)) {
&& (xmlStrcmp(nodeName, (const xmlChar *)"dict") == 0)) {
dmg_parsemsg("read: Found dict start\n");
stateDepth[DMG_FIND_BASE_DICT] = depth;
state++;
}
if ((state == DMG_FIND_BASE_PLIST) && (xmlStrcmp(nodeName, "plist") == 0)) {
if ((state == DMG_FIND_BASE_PLIST) && (xmlStrcmp(nodeName, (const xmlChar *)"plist") == 0)) {
dmg_parsemsg("read: Found plist start\n");
stateDepth[DMG_FIND_BASE_PLIST] = depth;
state++;
@ -498,13 +498,14 @@ int cli_scandmg(cli_ctx *ctx)
static int dmg_decode_mish(cli_ctx *ctx, unsigned int *mishblocknum, xmlChar *mish_base64,
struct dmg_mish_with_stripes *mish_set)
{
int ret = CL_CLEAN;
size_t base64_len, buff_size, decoded_len;
uint8_t *decoded;
const uint8_t mish_magic[4] = { 0x6d, 0x69, 0x73, 0x68 };
UNUSEDPARAM(ctx);
(*mishblocknum)++;
base64_len = strlen(mish_base64);
base64_len = strlen((const char *)mish_base64);
dmg_parsemsg("dmg_decode_mish: len of encoded block %u is %lu\n", *mishblocknum, base64_len);
/* speed vs memory, could walk the encoded data and skip whitespace in calculation */
@ -652,6 +653,8 @@ static int dmg_stripe_zeroes(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mi
ssize_t written;
uint8_t obuf[BUFSIZ];
UNUSEDPARAM(ctx);
cli_dbgmsg("dmg_stripe_zeroes: stripe " STDu32 "\n", index);
if (len == 0)
return CL_CLEAN;
@ -659,7 +662,7 @@ static int dmg_stripe_zeroes(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mi
memset(obuf, 0, sizeof(obuf));
while (len > sizeof(obuf)) {
written = cli_writen(fd, obuf, sizeof(obuf));
if (written != sizeof(obuf)) {
if ((size_t)written != sizeof(obuf)) {
ret = CL_EWRITE;
break;
}
@ -668,7 +671,7 @@ static int dmg_stripe_zeroes(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mi
if ((ret == CL_CLEAN) && (len > 0)) {
written = cli_writen(fd, obuf, len);
if (written != len) {
if ((size_t)written != len) {
ret = CL_EWRITE;
}
}
@ -684,7 +687,6 @@ static int dmg_stripe_zeroes(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mi
static int dmg_stripe_store(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mish_with_stripes *mish_set)
{
const void *obuf;
int ret;
size_t off = mish_set->stripes[index].dataOffset;
size_t len = mish_set->stripes[index].dataLength;
ssize_t written;
@ -703,7 +705,7 @@ static int dmg_stripe_store(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mis
cli_errmsg("dmg_stripe_store: error writing bytes to file (out of disk space?)\n");
return CL_EWRITE;
}
else if (written != len) {
else if ((size_t)written != len) {
cli_errmsg("dmg_stripe_store: error writing bytes to file (out of disk space?)\n");
return CL_EWRITE;
}
@ -713,7 +715,7 @@ static int dmg_stripe_store(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mis
/* Stripe handling: ADC block (type 0x80000004) */
static int dmg_stripe_adc(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mish_with_stripes *mish_set)
{
int ret = CL_CLEAN, adcret;
int adcret;
adc_stream strm;
size_t off = mish_set->stripes[index].dataOffset;
size_t len = mish_set->stripes[index].dataLength;
@ -796,7 +798,7 @@ static int dmg_stripe_adc(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mish_
/* Stripe handling: deflate block (type 0x80000005) */
static int dmg_stripe_inflate(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mish_with_stripes *mish_set)
{
int ret = CL_CLEAN, zstat;
int zstat;
z_stream strm;
size_t off = mish_set->stripes[index].dataOffset;
size_t len = mish_set->stripes[index].dataLength;
@ -905,7 +907,7 @@ static int dmg_stripe_bzip(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mish
#if HAVE_BZLIB_H
memset(&strm, 0, sizeof(strm));
strm.next_out = obuf;
strm.next_out = (char *)obuf;
strm.avail_out = sizeof(obuf);
if (BZ2_bzDecompressInit(&strm, 0, 0) != BZ_OK) {
cli_dbgmsg("dmg_stripe_bzip: bzDecompressInit failed\n");
@ -960,13 +962,13 @@ static int dmg_stripe_bzip(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mish
break;
}
if (cli_writen(fd, obuf, next_write) != next_write) {
if ((size_t)cli_writen(fd, obuf, next_write) != next_write) {
cli_dbgmsg("dmg_stripe_bzip: error writing to tmpfile\n");
ret = CL_EWRITE;
break;
}
strm.next_out = obuf;
strm.next_out = (char *)obuf;
strm.avail_out = sizeof(obuf);
if (rc == BZ_OK)
@ -989,13 +991,13 @@ static int dmg_stripe_bzip(cli_ctx *ctx, int fd, uint32_t index, struct dmg_mish
break;
}
if (cli_writen(fd, obuf, next_write) != next_write) {
if ((size_t)cli_writen(fd, obuf, next_write) != next_write) {
cli_dbgmsg("dmg_stripe_bzip: error writing to tmpfile\n");
ret = CL_EWRITE;
break;
}
strm.next_out = obuf;
strm.next_out = (char *)obuf;
strm.avail_out = sizeof(obuf);
}
} while ((rc == BZ_OK) && (len > 0));
@ -1154,7 +1156,7 @@ static int dmg_extract_xml(cli_ctx *ctx, char *dir, struct dmg_koly_block *hdr)
return CL_ETMPFILE;
}
if (cli_writen(ofd, outdata, hdr->xmlLength) != hdr->xmlLength) {
if ((uint64_t)cli_writen(ofd, outdata, hdr->xmlLength) != hdr->xmlLength) {
cli_errmsg("cli_scandmg: Not all bytes written!\n");
close(ofd);
free(xmlfile);

View file

@ -815,11 +815,7 @@ int cli_scanelf(cli_ctx *ctx)
int cli_elfheader(fmap_t *map, struct cli_exe_info *elfinfo)
{
union elf_file_hdr file_hdr;
struct elf_section_hdr32 *section_hdr = NULL;
struct elf_program_hdr32 *program_hdr = NULL;
uint16_t shnum, phnum, shentsize, phentsize, i;
uint64_t entry, fentry = 0, shoff, phoff;
uint8_t conv = 0, err, is64 = 0;
uint8_t conv = 0, is64 = 0;
int ret;
cli_dbgmsg("in cli_elfheader\n");

View file

@ -711,7 +711,6 @@ static int in_iconv_u16(const m_area_t* in_m_area, iconv_t* iconv_struct, m_area
char* input = (char*)in_m_area->buffer + in_m_area->offset;
size_t outleft = out_m_area->length > 0 ? out_m_area->length : 0;
char* out = (char*)out_m_area->buffer;
char err[128];
out_m_area->offset = 0;
if(!inleft) {
@ -734,7 +733,7 @@ static int in_iconv_u16(const m_area_t* in_m_area, iconv_t* iconv_struct, m_area
while (inleft && (outleft >= 2)) { /* iconv doesn't like inleft to be 0 */
const size_t outleft_last = outleft;
assert(*iconv_struct != (iconv_t)-1);
rc = iconv(*iconv_struct, &input, &inleft, &out, &outleft);
rc = iconv(*iconv_struct, (const char **)(&input), &inleft, &out, &outleft);
if(rc == (size_t)-1) {
if(errno == E2BIG) {
/* not enough space in output buffer */

View file

@ -120,6 +120,8 @@ static const struct ftmap_s {
{ NULL, CL_TYPE_IGNORED }
};
cli_file_t cli_partitiontype(const unsigned char *buf, size_t buflen, const struct cl_engine *engine);
cli_file_t cli_ftcode(const char *name)
{
unsigned int i;
@ -266,7 +268,7 @@ cli_file_t cli_filetype2(fmap_t *map, const struct cl_engine *engine, cli_file_t
int zi;
for (zi=0; zi<32; zi++) {
znamep = cli_memstr(znamep, zlen, lhdr_magic, 4);
znamep = (const unsigned char *)cli_memstr((const char *)znamep, zlen, lhdr_magic, 4);
if (NULL != znamep) {
znamep += SIZEOF_LH;
zlen = zread - (znamep - zbuff);

View file

@ -190,6 +190,8 @@ int filter_add_static(struct filter *m, const unsigned char *pattern, unsigned l
uint32_t best = 0xffffffff;
uint8_t best_pos = 0;
UNUSEDPARAM(name);
cli_perf_log_count(TRIE_ORIG_LEN, len > 8 ? 8 : len);
/* TODO: choose best among MAXCHOICES */
/* cut length */
@ -282,15 +284,6 @@ static inline unsigned char spec_ith_char(const struct char_spec *spec, unsigned
return i;
}
static const struct char_spec full_range = {NULL, 0,0xff,1,0};
static inline int spec_is_fullrange(const struct char_spec *spec0, const struct char_spec *spec1)
{
return !memcmp(spec0, &full_range, sizeof(full_range)) &&
!memcmp(spec1, &full_range, sizeof(full_range));
}
#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
@ -696,43 +689,6 @@ int filter_add_acpatt(struct filter *m, const struct cli_ac_patt *pat)
return j+2;
}
static const struct match_len_info {
uint8_t shortest;
uint8_t longest;
} match_len[256] = {
{2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{5,9},
{2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{6,9},
{2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{5,9},
{2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{7,9},
{2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{5,9},
{2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{6,9},
{2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{5,9},
{2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{8,9},
{2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{5,9},
{2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{6,9},
{2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{5,9},
{2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{7,9},
{2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{5,9},
{2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{6,9},
{2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{5,9},
{2,9},{3,9},{2,9},{4,9},{2,9},{3,9},{2,9},{9,9},
{2,8},{3,8},{2,8},{4,8},{2,8},{3,8},{2,8},{5,8},
{2,8},{3,8},{2,8},{4,8},{2,8},{3,8},{2,8},{6,8},
{2,8},{3,8},{2,8},{4,8},{2,8},{3,8},{2,8},{5,8},
{2,8},{3,8},{2,8},{4,8},{2,8},{3,8},{2,8},{7,8},
{2,8},{3,8},{2,8},{4,8},{2,8},{3,8},{2,8},{5,8},
{2,8},{3,8},{2,8},{4,8},{2,8},{3,8},{2,8},{6,8},
{2,8},{3,8},{2,8},{4,8},{2,8},{3,8},{2,8},{5,8},
{2,8},{3,8},{2,8},{4,8},{2,8},{3,8},{2,8},{8,8},
{2,7},{3,7},{2,7},{4,7},{2,7},{3,7},{2,7},{5,7},
{2,7},{3,7},{2,7},{4,7},{2,7},{3,7},{2,7},{6,7},
{2,7},{3,7},{2,7},{4,7},{2,7},{3,7},{2,7},{5,7},
{2,7},{3,7},{2,7},{4,7},{2,7},{3,7},{2,7},{7,7},
{2,6},{3,6},{2,6},{4,6},{2,6},{3,6},{2,6},{5,6},
{2,6},{3,6},{2,6},{4,6},{2,6},{3,6},{2,6},{6,6},
{2,5},{3,5},{2,5},{4,5},{2,5},{3,5},{2,5},{5,5},
{2,4},{3,4},{2,4},{4,4},{2,3},{3,3},{2,2},{0,0}
};
/* state 11110011 means that we may have a match of length min 4, max 5 */
__hot__ int filter_search_ext(const struct filter *m, const unsigned char *data, unsigned long len, struct filter_match_info *inf)

View file

@ -62,12 +62,8 @@ static off_t pread_cb(void *handle, void *buf, size_t count, off_t offset)
fmap_t *fmap_check_empty(int fd, off_t offset, size_t len, int *empty) {
unsigned int pages, mapsz, hdrsz;
unsigned short dumb = 1;
int pgsz = cli_getpagesize();
STATBUF st;
fmap_t *m;
void *handle = (void*)(ssize_t)fd;
*empty = 0;
if(FSTAT(fd, &st)) {
@ -215,7 +211,7 @@ extern cl_fmap_t *cl_fmap_open_handle(void *handle, size_t offset, size_t len,
cl_fmap_t *m;
int pgsz = cli_getpagesize();
if(offset < 0 || offset != fmap_align_to(offset, pgsz)) {
if((off_t)offset < 0 || offset != fmap_align_to(offset, pgsz)) {
cli_warnmsg("fmap: attempted mapping with unaligned offset\n");
return NULL;
}
@ -651,8 +647,6 @@ static void mem_unneed_off(fmap_t *m, size_t at, size_t len);
static const void *mem_need_offstr(fmap_t *m, size_t at, size_t len_hint);
static const void *mem_gets(fmap_t *m, char *dst, size_t *at, size_t max_len);
static void unmap_none(fmap_t *m) {}
extern cl_fmap_t *cl_fmap_open_memory(const void *start, size_t len)
{
int pgsz = cli_getpagesize();
@ -676,6 +670,7 @@ extern cl_fmap_t *cl_fmap_open_memory(const void *start, size_t len)
static const void *mem_need(fmap_t *m, size_t at, size_t len, int lock) { /* WIN32 */
UNUSEDPARAM(lock);
if(!len) {
return NULL;
}
@ -687,7 +682,12 @@ static const void *mem_need(fmap_t *m, size_t at, size_t len, int lock) { /* WIN
return (void *)((char *)m->data + at);
}
static void mem_unneed_off(fmap_t *m, size_t at, size_t len) {}
static void mem_unneed_off(fmap_t *m, size_t at, size_t len)
{
UNUSEDPARAM(m);
UNUSEDPARAM(at);
UNUSEDPARAM(len);
}
static const void *mem_need_offstr(fmap_t *m, size_t at, size_t len_hint) {
char *ptr = (char *)m->data + at;
@ -759,7 +759,7 @@ int fmap_dump_to_file(fmap_t *map, const char *tmpdir, char **outname, int *outf
b = fmap_need_off_once_len(map, pos, BUFSIZ, &len);
pos += len;
if(b && (len > 0)) {
if (cli_writen(tmpfd, b, len) != len) {
if ((size_t)cli_writen(tmpfd, b, len) != len) {
cli_warnmsg("fmap_dump_to_file: write failed to %s!\n", tmpname);
close(tmpfd);
unlink(tmpname);
@ -780,7 +780,7 @@ int fmap_dump_to_file(fmap_t *map, const char *tmpdir, char **outname, int *outf
int fmap_fd(fmap_t *m)
{
int fd, ret;
int fd;
if (!m->handle_is_fd)
return -1;
fd = (int)(ssize_t)m->handle;

View file

@ -78,22 +78,22 @@ size_t gpt_detect_size(fmap_t *map)
buff = (unsigned char*)fmap_need_off_once(map, 512, 8);
if (!buff) return 0;
if (0 == strncmp(buff, GPT_SIGNATURE_STR, 8))
if (0 == strncmp((const char *)buff, GPT_SIGNATURE_STR, 8))
return 512;
buff = (unsigned char*)fmap_need_off_once(map, 1024, 8);
if (!buff) return 0;
if (0 == strncmp(buff, GPT_SIGNATURE_STR, 8))
if (0 == strncmp((const char *)buff, GPT_SIGNATURE_STR, 8))
return 1024;
buff = (unsigned char*)fmap_need_off_once(map, 2048, 8);
if (!buff) return 0;
if (0 == strncmp(buff, GPT_SIGNATURE_STR, 8))
if (0 == strncmp((const char *)buff, GPT_SIGNATURE_STR, 8))
return 2048;
buff = (unsigned char*)fmap_need_off_once(map, 4096, 8);
if (!buff) return 0;
if (0 == strncmp(buff, GPT_SIGNATURE_STR, 8))
if (0 == strncmp((const char *)buff, GPT_SIGNATURE_STR, 8))
return 4096;
return 0;
@ -571,6 +571,8 @@ static void gpt_printSectors(cli_ctx *ctx, size_t sectorsize)
gpt_parsemsg("%llu-%llu: Secondary GPT Partition Table\n", shdr.tableStartLBA, stableLastLBA);
gpt_parsemsg("%llu: Secondary GPT Header\n", phdr.backupLBA);
#else
UNUSEDPARAM(ctx);
UNUSEDPARAM(sectorsize);
return;
#endif
}

View file

@ -931,7 +931,7 @@ int cli_map_removekey(struct cli_map *m, const void *key, int32_t keysize)
int cli_map_setvalue(struct cli_map *m, const void* value, int32_t valuesize)
{
if ((m->valuesize && m->valuesize != valuesize)
|| m->last_insert >= m->nvalues || m->last_insert < 0)
|| (uint32_t)(m->last_insert) >= m->nvalues || m->last_insert < 0)
return -CL_EARG;
if (m->valuesize) {
memcpy((char*)m->u.sized_values + m->last_insert * m->valuesize,
@ -967,14 +967,14 @@ int cli_map_getvalue_size(struct cli_map *m)
{
if (m->valuesize)
return m->valuesize;
if (m->last_find < 0 || m->last_find >= m->nvalues)
if (m->last_find < 0 || (uint32_t)(m->last_find) >= m->nvalues)
return -CL_EARG;
return m->u.unsized_values[m->last_find].valuesize;
}
void* cli_map_getvalue(struct cli_map *m)
{
if (m->last_find < 0 || m->last_find >= m->nvalues)
if (m->last_find < 0 || (uint32_t)(m->last_find) >= m->nvalues)
return NULL;
if (m->valuesize)
return (char*)m->u.sized_values + m->last_find*m->valuesize;

View file

@ -300,6 +300,8 @@ static int hfsplus_scanfile(cli_ctx *ctx, hfsPlusVolumeHeader *volHeader, hfsHea
uint32_t outputBlocks = 0;
uint8_t ext;
UNUSEDPARAM(extHeader);
/* bad record checks */
if (!fork || (fork->logicalSize == 0) || (fork->totalBlocks == 0)) {
cli_dbgmsg("hfsplus_dumpfile: Empty file.\n");
@ -381,7 +383,7 @@ static int hfsplus_scanfile(cli_ctx *ctx, hfsPlusVolumeHeader *volHeader, hfsHea
break;
}
written = cli_writen(ofd, mPtr, to_write);
if (written != to_write) {
if ((size_t)written != to_write) {
cli_errmsg("hfsplus_dumpfile: write error\n");
ret = CL_EWRITE;
break;
@ -425,6 +427,8 @@ static int hfsplus_validate_catalog(cli_ctx *ctx, hfsPlusVolumeHeader *volHeader
{
hfsPlusForkData *catFork;
UNUSEDPARAM(ctx);
catFork = &(volHeader->catalogFile);
if (catFork->totalBlocks >= volHeader->totalBlocks) {
cli_dbgmsg("hfsplus_getnodelimit: catFork totalBlocks too large!\n");
@ -446,13 +450,15 @@ static int hfsplus_validate_catalog(cli_ctx *ctx, hfsPlusVolumeHeader *volHeader
static int hfsplus_fetch_node (cli_ctx *ctx, hfsPlusVolumeHeader *volHeader, hfsHeaderRecord *catHeader,
hfsHeaderRecord *extHeader, uint32_t node, uint8_t *buff)
{
int foundBlock = 0, ret = CL_CLEAN;
int foundBlock = 0;
uint64_t catalogOffset;
uint32_t fetchBlock, fetchStart;
uint32_t extentNum = 0, realFileBlock;
size_t fileOffset = 0;
hfsPlusForkData *catFork;
UNUSEDPARAM(extHeader);
/* Make sure node is in range */
if (node >= catHeader->totalNodes) {
cli_dbgmsg("hfsplus_fetch_node: invalid node number " STDu32 "\n", node);
@ -534,15 +540,6 @@ static int hfsplus_fetch_node (cli_ctx *ctx, hfsPlusVolumeHeader *volHeader, hfs
return CL_CLEAN;
}
/* Given the catalog and other details, scan all the volume contents */
static int hfsplus_scan_node(cli_ctx *ctx, hfsPlusVolumeHeader *volHeader, hfsHeaderRecord *catHeader,
hfsHeaderRecord *extHeader, const char *dirname, uint8_t *nodeBuf)
{
int ret = CL_CLEAN;
return ret;
}
/* Given the catalog and other details, scan all the volume contents */
static int hfsplus_walk_catalog(cli_ctx *ctx, hfsPlusVolumeHeader *volHeader, hfsHeaderRecord *catHeader,
hfsHeaderRecord *extHeader, const char *dirname)

View file

@ -62,6 +62,8 @@
#include "hostid.h"
#include "libclamav/others.h"
struct device *get_device_entry(struct device *devices, size_t *ndevices, const char *name);
struct device *get_device_entry(struct device *devices, size_t *ndevices, const char *name)
{
void *p;

View file

@ -256,7 +256,7 @@ int cli_scanishield_msi(cli_ctx *ctx, off_t off) {
while(csize) {
uint8_t buf2[BUFSIZ];
z.avail_in = MIN(csize, sizeof(buf2));
if(fmap_readn(map, buf2, off, z.avail_in) != z.avail_in) {
if((uInt)fmap_readn(map, buf2, off, z.avail_in) != z.avail_in) {
cli_dbgmsg("ishield-msi: premature EOS or read fail\n");
break;
}
@ -373,7 +373,7 @@ int cli_scanishield(cli_ctx *ctx, off_t off, size_t sz) {
if(fsize < 0 || fsize == LONG_MAX ||
!*strsz || !eostr || eostr == strsz || *eostr ||
(unsigned long)fsize >= sz ||
data - fname >= sz - fsize
(size_t)(data - fname) >= sz - fsize
) break;
cli_dbgmsg("ishield: @%lx found file %s (%s) - version %s - size %lu\n", (unsigned long int) coff, fname, path, version, (unsigned long int) fsize);

View file

@ -70,7 +70,7 @@ static int iso_scan_file(const iso9660_t *iso, unsigned int block, unsigned int
ret = CL_EFORMAT;
break;
}
if(cli_writen(fd, buf, todo) != todo) {
if((unsigned int)cli_writen(fd, buf, todo) != todo) {
cli_warnmsg("iso_scan_file: Can't write to file %s\n", tmpf);
ret = CL_EWRITE;
break;

View file

@ -65,7 +65,7 @@ int json_object_object_get_ex(struct json_object *obj, const char *key, struct j
#define nojson_func cli_dbgmsg
/* internal functions */
int cli_json_nojson();
int cli_json_nojson(void);
int cli_jsonnull_nojson(const char* key);
int cli_jsonstr_nojson(const char* key, const char* s);

View file

@ -53,8 +53,6 @@
*
*/
static char const rcsid[] = "$Id: line.c,v 1.11 2007/02/12 20:46:08 njh Exp $";
#if HAVE_CONFIG_H
#include "clamav-config.h"
#endif

View file

@ -28,9 +28,9 @@
#include "lzma_iface.h"
void *__lzma_wrap_alloc(void *unused, size_t size) {
UNUSEDPARAM(unused);
if(!size || size > CLI_MAX_ALLOCATION)
return NULL;
unused = unused;
if(!size || size > CLI_MAX_ALLOCATION) {
cli_dbgmsg("lzma_wrap_alloc(): Attempt to allocate %lu bytes.\n", (unsigned long int) size);
return NULL;
@ -39,7 +39,7 @@ void *__lzma_wrap_alloc(void *unused, size_t size) {
return cli_malloc(size);
}
void __lzma_wrap_free(void *unused, void *freeme) {
unused = unused;
UNUSEDPARAM(unused);
free(freeme);
}
static ISzAlloc g_Alloc = { __lzma_wrap_alloc, __lzma_wrap_free };

View file

@ -293,10 +293,8 @@ static int ac_maketrans(struct cli_matcher *root)
{
struct bfs_list *bfs = NULL, *bfs_last = NULL;
struct cli_ac_node *ac_root = root->ac_root, *child, *node, *fail;
struct cli_ac_patt *patt;
int i, ret;
for(i = 0; i < 256; i++) {
node = ac_root->trans[i];
if(!node) {
@ -911,6 +909,7 @@ int cli_ac_initdata(struct cli_ac_data *data, uint32_t partsigs, uint32_t lsigs,
{
unsigned int i, j;
UNUSEDPARAM(tracklen);
if(!data) {
cli_errmsg("cli_ac_init: data == NULL\n");
@ -1360,7 +1359,7 @@ int cli_ac_scanbuff(const unsigned char *buffer, uint32_t length, const char **v
if(res) {
newres = (struct cli_ac_result *) malloc(sizeof(struct cli_ac_result));
if(!newres) {
cli_errmsg("cli_ac_scanbuff: Can't allocate memory for newres %u\n", sizeof(struct cli_ac_result));
cli_errmsg("cli_ac_scanbuff: Can't allocate memory for newres %lu\n", sizeof(struct cli_ac_result));
return CL_EMEM;
}
newres->virname = pt->virname;
@ -1413,7 +1412,7 @@ int cli_ac_scanbuff(const unsigned char *buffer, uint32_t length, const char **v
if(res) {
newres = (struct cli_ac_result *) malloc(sizeof(struct cli_ac_result));
if(!newres) {
cli_errmsg("cli_ac_scanbuff: Can't allocate memory for newres %u\n", sizeof(struct cli_ac_result));
cli_errmsg("cli_ac_scanbuff: Can't allocate memory for newres %lu\n", sizeof(struct cli_ac_result));
return CL_EMEM;
}
newres->virname = pt->virname;

View file

@ -72,8 +72,19 @@ static inline int PERF_LOG_TRIES(int8_t acmode, int8_t bm_called, int32_t length
}
#else
static inline void PERF_LOG_FILTER(int32_t pos, uint32_t length, int8_t trie) {}
static inline int PERF_LOG_TRIES(int8_t acmode, int8_t bm_called, int32_t length) { return 0; }
static inline void PERF_LOG_FILTER(int32_t pos, uint32_t length, int8_t trie) {
UNUSEDPARAM(pos);
UNUSEDPARAM(length);
UNUSEDPARAM(trie);
}
static inline int PERF_LOG_TRIES(int8_t acmode, int8_t bm_called, int32_t length) {
UNUSEDPARAM(acmode);
UNUSEDPARAM(bm_called);
UNUSEDPARAM(length);
return 0;
}
#endif
static inline int matcher_run(const struct cli_matcher *root,
@ -97,6 +108,8 @@ static inline int matcher_run(const struct cli_matcher *root,
const unsigned char* orig_buffer;
unsigned int viruses_found = 0;
UNUSEDPARAM(map);
if (root->filter) {
if(filter_search_ext(root->filter, buffer, length, &info) == -1) {
/* for safety always scan last maxpatlen bytes */
@ -529,7 +542,7 @@ int cli_checkfp(unsigned char *digest, size_t size, cli_ctx *ctx)
}
if (ctx->engine->cb_hash)
ctx->engine->cb_hash(fmap_fd(*ctx->fmap), size, md5, cli_get_last_virus(ctx), ctx->cb_ctx);
ctx->engine->cb_hash(fmap_fd(*ctx->fmap), size, (const unsigned char *)md5, cli_get_last_virus(ctx), ctx->cb_ctx);
if (ctx->engine->cb_stats_add_sample)
ctx->engine->cb_stats_add_sample(cli_get_last_virus(ctx), digest, size, &sections, ctx->engine->stats_data);
@ -925,11 +938,11 @@ int cli_fmap_scandesc(cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struct cli
uint32_t data_len = bytes - maxpatlen * (offset!=0);
if(compute_hash[CLI_HASH_MD5])
cl_update_hash(md5ctx, data, data_len);
cl_update_hash(md5ctx, (void *)data, data_len);
if(compute_hash[CLI_HASH_SHA1])
cl_update_hash(sha1ctx, data, data_len);
cl_update_hash(sha1ctx, (void *)data, data_len);
if(compute_hash[CLI_HASH_SHA256])
cl_update_hash(sha256ctx, data, data_len);
cl_update_hash(sha256ctx, (void *)data, data_len);
}
}
@ -1023,7 +1036,7 @@ int cli_fmap_scandesc(cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struct cli
if(troot) {
if(ret != CL_VIRUS || SCAN_ALL)
ret = cli_lsig_eval(ctx, troot, &tdata, &info, refhash);
ret = cli_lsig_eval(ctx, troot, &tdata, &info, (const char *)refhash);
if (ret == CL_VIRUS)
viruses_found++;
@ -1034,7 +1047,7 @@ int cli_fmap_scandesc(cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struct cli
if(groot) {
if(ret != CL_VIRUS || SCAN_ALL)
ret = cli_lsig_eval(ctx, groot, &gdata, &info, refhash);
ret = cli_lsig_eval(ctx, groot, &gdata, &info, (const char *)refhash);
cli_ac_freedata(&gdata);
}

View file

@ -18,8 +18,6 @@
* MA 02110-1301, USA.
*/
static char const rcsid[] = "$Id: mbox.c,v 1.381 2007/02/15 12:26:44 njh Exp $";
#if HAVE_CONFIG_H
#include "clamav-config.h"
#endif
@ -2144,7 +2142,7 @@ boundaryStart(const char *line, const char *boundary)
newline = strdup(line);
if (!(newline))
newline = line;
newline = (char *)line;
if (newline != line && strlen(newline)) {
char *p;
@ -2266,7 +2264,8 @@ boundaryEnd(const char *line, const char *boundary)
p = newline = strdup(line);
if (!(newline)) {
p = newline = line;
p = (char *)line;
newline = (char *)line;
}
if (newline != line && strlen(newline)) {
@ -2508,7 +2507,7 @@ parseMimeHeader(message *m, const char *cmd, const table_t *rfc821Table, const c
buf = cli_malloc(strlen(ptr) + 1);
if(buf == NULL) {
cli_errmsg("parseMimeHeader: Unable to allocate memory for buf %u\n", strlen(ptr) + 1);
cli_errmsg("parseMimeHeader: Unable to allocate memory for buf %lu\n", strlen(ptr) + 1);
if(copy)
free(copy);
return -1;
@ -2617,7 +2616,7 @@ parseMimeHeader(message *m, const char *cmd, const table_t *rfc821Table, const c
case CONTENT_DISPOSITION:
buf = cli_malloc(strlen(ptr) + 1);
if(buf == NULL) {
cli_errmsg("parseMimeHeader: Unable to allocate memory for buf %u\n", strlen(ptr) + 1);
cli_errmsg("parseMimeHeader: Unable to allocate memory for buf %lu\n", strlen(ptr) + 1);
if(copy)
free(copy);
return -1;
@ -2695,7 +2694,7 @@ rfc822comments(const char *in, char *out)
if(out == NULL) {
out = cli_malloc(strlen(in) + 1);
if(out == NULL) {
cli_errmsg("rfc822comments: Unable to allocate memory for out %u\n", strlen(in) + 1);
cli_errmsg("rfc822comments: Unable to allocate memory for out %lu\n", strlen(in) + 1);
return NULL;
}
}
@ -2763,7 +2762,7 @@ rfc2047(const char *in)
out = cli_malloc(strlen(in) + 1);
if(out == NULL) {
cli_errmsg("rfc2047: Unable to allocate memory for out %u\n", strlen(in) + 1);
cli_errmsg("rfc2047: Unable to allocate memory for out %lu\n", strlen(in) + 1);
return NULL;
}
@ -3197,6 +3196,8 @@ checkURLs(message *mainMessage, mbox_ctx *mctx, mbox_status *rc, int is_html)
blob *b;
tag_arguments_t hrefs;
UNUSEDPARAM(is_html);
if(*rc == VIRUS)
return;

View file

@ -67,7 +67,6 @@ enum MBR_STATE {
static int mbr_scanextprtn(cli_ctx *ctx, unsigned *prtncount, off_t extlba,
size_t extlbasize, size_t sectorsize);
static void mbr_printbr(struct mbr_boot_record *record);
static int mbr_check_mbr(struct mbr_boot_record *record, size_t maplen, size_t sectorsize);
static int mbr_check_ebr(struct mbr_boot_record *record);
static int mbr_primary_prtn_intxn(cli_ctx *ctx, struct mbr_boot_record mbr, size_t sectorsize);
@ -425,24 +424,6 @@ void mbr_convert_to_host(struct mbr_boot_record *record)
record->signature = be16_to_host(record->signature);
}
static void mbr_printbr(struct mbr_boot_record *record)
{
unsigned i;
cli_dbgmsg("signature: %x\n", record->signature);
for (i = 0; i < MBR_MAX_PARTITION_ENTRIES; ++i) {
cli_dbgmsg("entry %u:\n", i);
cli_dbgmsg("\tstatus: %x\n", record->entries[i].status);
cli_dbgmsg("\tfirstCHS: [%u, %u, %u]\n", record->entries[i].firstCHS[0],
record->entries[i].firstCHS[1], record->entries[i].firstCHS[2]);
cli_dbgmsg("\ttype: %x\n", record->entries[i].type);
cli_dbgmsg("\tlastCHS: [%u, %u, %u]\n", record->entries[i].lastCHS[0],
record->entries[i].lastCHS[1], record->entries[i].lastCHS[2]);
cli_dbgmsg("\tfirstLBA: %u\n", record->entries[i].firstLBA);
cli_dbgmsg("\tnumLBA: %u\n", record->entries[i].numLBA);
}
}
static int mbr_check_mbr(struct mbr_boot_record *record, size_t maplen, size_t sectorsize)
{
unsigned i = 0;

View file

@ -19,7 +19,6 @@
*
* TODO: Optimise messageExport, decodeLine, messageIsEncoding
*/
static char const rcsid[] = "$Id: message.c,v 1.195 2007/02/12 20:46:09 njh Exp $";
#if HAVE_CONFIG_H
#include "clamav-config.h"

View file

@ -58,7 +58,7 @@
#ifdef DEBUGMPOOL
#define spam(...) cli_warnmsg( __VA_ARGS__)
#else
static inline void spam(const char *fmt, ...) { fmt = fmt; } /* gcc STFU */
static inline void spam(const char *fmt, ...) { UNUSEDPARAM(fmt); }
#endif
#include "mpool.h"

View file

@ -127,7 +127,7 @@ static int mszip_read_input(struct mszip_stream *zip) {
int nread = zip->read_cb(zip->file, zip->inbuf, (int)zip->inbuf_size);
if (nread < 0) {
if (zip->file->error == CL_BREAK) {
if (nread == zip->last) {
if ((unsigned int)nread == zip->last) {
cli_dbgmsg("mszip_read_input: Two consecutive CL_BREAKs reached.\n");
return CL_BREAK;
}

View file

@ -34,61 +34,6 @@
#include "bzlib_private.h"
#include "others.h"
static const Int32 BZ2_rNums[512] = {
619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
419, 436, 278, 496, 867, 210, 399, 680, 480, 51,
878, 465, 811, 169, 869, 675, 611, 697, 867, 561,
862, 687, 507, 283, 482, 129, 807, 591, 733, 623,
150, 238, 59, 379, 684, 877, 625, 169, 643, 105,
170, 607, 520, 932, 727, 476, 693, 425, 174, 647,
73, 122, 335, 530, 442, 853, 695, 249, 445, 515,
909, 545, 703, 919, 874, 474, 882, 500, 594, 612,
641, 801, 220, 162, 819, 984, 589, 513, 495, 799,
161, 604, 958, 533, 221, 400, 386, 867, 600, 782,
382, 596, 414, 171, 516, 375, 682, 485, 911, 276,
98, 553, 163, 354, 666, 933, 424, 341, 533, 870,
227, 730, 475, 186, 263, 647, 537, 686, 600, 224,
469, 68, 770, 919, 190, 373, 294, 822, 808, 206,
184, 943, 795, 384, 383, 461, 404, 758, 839, 887,
715, 67, 618, 276, 204, 918, 873, 777, 604, 560,
951, 160, 578, 722, 79, 804, 96, 409, 713, 940,
652, 934, 970, 447, 318, 353, 859, 672, 112, 785,
645, 863, 803, 350, 139, 93, 354, 99, 820, 908,
609, 772, 154, 274, 580, 184, 79, 626, 630, 742,
653, 282, 762, 623, 680, 81, 927, 626, 789, 125,
411, 521, 938, 300, 821, 78, 343, 175, 128, 250,
170, 774, 972, 275, 999, 639, 495, 78, 352, 126,
857, 956, 358, 619, 580, 124, 737, 594, 701, 612,
669, 112, 134, 694, 363, 992, 809, 743, 168, 974,
944, 375, 748, 52, 600, 747, 642, 182, 862, 81,
344, 805, 988, 739, 511, 655, 814, 334, 249, 515,
897, 955, 664, 981, 649, 113, 974, 459, 893, 228,
433, 837, 553, 268, 926, 240, 102, 654, 459, 51,
686, 754, 806, 760, 493, 403, 415, 394, 687, 700,
946, 670, 656, 610, 738, 392, 760, 799, 887, 653,
978, 321, 576, 617, 626, 502, 894, 679, 243, 440,
680, 879, 194, 572, 640, 724, 926, 56, 204, 700,
707, 151, 457, 449, 797, 195, 791, 558, 945, 679,
297, 59, 87, 824, 713, 663, 412, 693, 342, 606,
134, 108, 571, 364, 631, 212, 174, 643, 304, 329,
343, 97, 430, 751, 497, 314, 983, 374, 822, 928,
140, 206, 73, 263, 980, 736, 876, 478, 430, 305,
170, 514, 364, 692, 829, 82, 855, 953, 676, 246,
369, 970, 294, 750, 807, 827, 150, 790, 288, 923,
804, 378, 215, 828, 592, 281, 565, 555, 710, 82,
896, 831, 547, 261, 524, 462, 293, 465, 502, 56,
661, 821, 976, 991, 658, 869, 905, 758, 745, 193,
768, 550, 608, 933, 378, 286, 215, 979, 792, 961,
61, 688, 793, 644, 986, 403, 106, 366, 905, 644,
372, 567, 466, 434, 645, 210, 389, 550, 919, 135,
780, 773, 635, 389, 707, 100, 626, 958, 165, 504,
920, 176, 193, 713, 857, 265, 203, 50, 668, 108,
645, 990, 626, 197, 510, 357, 358, 850, 858, 364,
936, 638
};
/*---------------------------------------------------*/
static
void makeMaps_d ( DState* s )
@ -1045,14 +990,16 @@ int bz_config_ok ( void )
static
void* default_bzalloc ( void* opaque, Int32 items, Int32 size )
{
void* v = cli_malloc ( items * size );
return v;
UNUSEDPARAM(opaque);
void* v = cli_malloc ( items * size );
return v;
}
static
void default_bzfree ( void* opaque, void* addr )
{
if (addr != NULL) free ( addr );
UNUSEDPARAM(opaque);
if (addr != NULL) free ( addr );
}
/*---------------------------------------------------*/

View file

@ -187,7 +187,7 @@ static int nsis_decomp(struct nsis_st *n) {
static int nsis_unpack_next(struct nsis_st *n, cli_ctx *ctx) {
const unsigned char *ibuf;
uint32_t size, loops;
int ret, gotsome=0, opened=0;
int ret, gotsome=0;
unsigned char obuf[BUFSIZ];
if (n->eof) {

View file

@ -32,6 +32,8 @@
#endif
#include "json_api.h"
#include "ooxml.h"
#if HAVE_LIBXML2
#ifdef _WIN32
#ifndef LIBXML_WRITER_ENABLED
@ -74,17 +76,17 @@ static int ooxml_parse_value(json_object *wrkptr, const char *arrname, const xml
return CL_EMEM;
}
if (ooxml_is_int(node_value, xmlStrlen(node_value), &val)) {
if (ooxml_is_int((const char *)node_value, xmlStrlen(node_value), &val)) {
newobj = json_object_new_int(val);
}
else if (!xmlStrcmp(node_value, "true")) {
else if (!xmlStrcmp(node_value, (const xmlChar *)"true")) {
newobj = json_object_new_boolean(1);
}
else if (!xmlStrcmp(node_value, "false")) {
else if (!xmlStrcmp(node_value, (const xmlChar *)"false")) {
newobj = json_object_new_boolean(0);
}
else {
newobj = json_object_new_string(node_value);
newobj = json_object_new_string((const char *)node_value);
}
if (NULL == newobj) {
@ -218,7 +220,7 @@ static int ooxml_parse_element(cli_ctx *ctx, xmlTextReaderPtr reader, json_objec
/* check recursion level */
if (rlvl >= OOXML_JSON_RECLEVEL_MAX) {
cli_dbgmsg("ooxml_parse_element: reached ooxml json recursion limit\n", node_name);
cli_dbgmsg("ooxml_parse_element: reached ooxml json recursion limit\n");
/* skip it */
xmlTextReaderNext(reader);
//return CL_EMAXREC;
@ -238,7 +240,7 @@ static int ooxml_parse_element(cli_ctx *ctx, xmlTextReaderPtr reader, json_objec
cli_dbgmsg("ooxml_parse_element: element tag node nameless\n");
return CL_EPARSE; /* no name, nameless */
}
element_tag = ooxml_check_key(node_name, xmlStrlen(node_name));
element_tag = ooxml_check_key((const char *)node_name, xmlStrlen(node_name));
if (!element_tag) {
cli_dbgmsg("ooxml_parse_element: invalid element tag [%s]\n", node_name);
/* skip it */
@ -274,7 +276,7 @@ static int ooxml_parse_element(cli_ctx *ctx, xmlTextReaderPtr reader, json_objec
cli_dbgmsg("%s: %s\n", name, value);
cli_jsonstr(attributes, name, value);
cli_jsonstr(attributes, name, (const char *)value);
}
}
@ -310,7 +312,7 @@ static int ooxml_parse_element(cli_ctx *ctx, xmlTextReaderPtr reader, json_objec
return CL_EPARSE; /* no name, nameless */
}
end_tag = ooxml_check_key(node_name, xmlStrlen(node_name));
end_tag = ooxml_check_key((const char *)node_name, xmlStrlen(node_name));
if (!end_tag) {
cli_dbgmsg("ooxml_parse_element: invalid element end tag [%s]\n", node_name);
return CL_EFORMAT; /* unrecognized element tag */
@ -426,7 +428,7 @@ static int ooxml_content_cb(int fd, cli_ctx *ctx)
name = xmlTextReaderConstLocalName(reader);
if (name == NULL) continue;
if (strcmp(name, "Override")) continue;
if (strcmp((const char *)name, "Override")) continue;
if (!xmlTextReaderHasAttributes(reader)) continue;
@ -436,10 +438,10 @@ static int ooxml_content_cb(int fd, cli_ctx *ctx)
value = xmlTextReaderConstValue(reader);
if (name == NULL || value == NULL) continue;
if (!xmlStrcmp(name, "ContentType")) {
if (!xmlStrcmp(name, (const xmlChar *)"ContentType")) {
CT = value;
}
else if (!xmlStrcmp(name, "PartName")) {
else if (!xmlStrcmp(name, (const xmlChar *)"PartName")) {
PN = value;
}
@ -448,10 +450,10 @@ static int ooxml_content_cb(int fd, cli_ctx *ctx)
if (!CT && !PN) continue;
if (!xmlStrcmp(CT, "application/vnd.openxmlformats-package.core-properties+xml")) {
if (!xmlStrcmp(CT, (const xmlChar *)"application/vnd.openxmlformats-package.core-properties+xml")) {
if (!core) {
/* default: /docProps/core.xml*/
tmp = unzip_search(ctx, PN+1, xmlStrlen(PN)-1, &loff);
tmp = unzip_search(ctx, (const char *)(PN+1), xmlStrlen(PN)-1, &loff);
if (tmp == CL_ETIMEOUT) {
ret = tmp;
}
@ -466,10 +468,10 @@ static int ooxml_content_cb(int fd, cli_ctx *ctx)
}
}
}
else if (!xmlStrcmp(CT, "application/vnd.openxmlformats-officedocument.extended-properties+xml")) {
else if (!xmlStrcmp(CT, (const xmlChar *)"application/vnd.openxmlformats-officedocument.extended-properties+xml")) {
if (!extn) {
/* default: /docProps/app.xml */
tmp = unzip_search(ctx, PN+1, xmlStrlen(PN)-1, &loff);
tmp = unzip_search(ctx, (const char *)(PN+1), xmlStrlen(PN)-1, &loff);
if (tmp == CL_ETIMEOUT) {
ret = tmp;
}
@ -484,10 +486,10 @@ static int ooxml_content_cb(int fd, cli_ctx *ctx)
}
}
}
else if (!xmlStrcmp(CT, "application/vnd.openxmlformats-officedocument.custom-properties+xml")) {
else if (!xmlStrcmp(CT, (const xmlChar *)"application/vnd.openxmlformats-officedocument.custom-properties+xml")) {
if (!cust) {
/* default: /docProps/custom.xml */
tmp = unzip_search(ctx, PN+1, xmlStrlen(PN)-1, &loff);
tmp = unzip_search(ctx, (const char *)(PN+1), xmlStrlen(PN)-1, &loff);
if (tmp == CL_ETIMEOUT) {
ret = tmp;
}
@ -502,7 +504,7 @@ static int ooxml_content_cb(int fd, cli_ctx *ctx)
}
}
}
else if (!xmlStrcmp(CT, "application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml")) {
else if (!xmlStrcmp(CT, (const xmlChar *)"application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml")) {
dsig++;
}
@ -566,6 +568,7 @@ int cli_process_ooxml(cli_ctx *ctx)
return unzip_single_internal(ctx, loff, ooxml_content_cb);
#else
UNUSEDPARAM(ctx);
cli_dbgmsg("in cli_processooxml\n");
#if !HAVE_LIBXML2
cli_dbgmsg("cli_process_ooxml: libxml2 needs to enabled!");

View file

@ -252,7 +252,7 @@ int openioc_parse(const char * fname, int fd, struct cl_engine *engine, unsigned
elem = elems;
elems = elems->next;
hash = elem->hash;
hash = (char *)(elem->hash);
while (isspace(*hash))
hash++;
hashlen = strlen(hash);

View file

@ -286,6 +286,8 @@ int cl_init(unsigned int initoptions)
struct timeval tv;
unsigned int pid = (unsigned int) getpid();
UNUSEDPARAM(initoptions);
cl_initialize_crypto();
{
@ -766,8 +768,6 @@ struct cl_settings *cl_engine_settings_copy(const struct cl_engine *engine)
int cl_engine_settings_apply(struct cl_engine *engine, const struct cl_settings *settings)
{
cli_intel_t *intel;
engine->ac_only = settings->ac_only;
engine->ac_mindepth = settings->ac_mindepth;
engine->ac_maxdepth = settings->ac_maxdepth;
@ -1163,7 +1163,7 @@ int cli_rmdirs(const char *dirname)
if(strcmp(dent->d_name, ".") && strcmp(dent->d_name, "..")) {
path = cli_malloc(strlen(dirname) + strlen(dent->d_name) + 2);
if(!path) {
cli_errmsg("cli_rmdirs: Unable to allocate memory for path %u\n", strlen(dirname) + strlen(dent->d_name) + 2);
cli_errmsg("cli_rmdirs: Unable to allocate memory for path %lu\n", strlen(dirname) + strlen(dent->d_name) + 2);
closedir(dd);
return -1;
}

View file

@ -121,6 +121,9 @@ uint8_t cli_always_gen_section_hash = 0;
static void fputs_callback(enum cl_msg severity, const char *fullmsg, const char *msg, void *context)
{
UNUSEDPARAM(severity);
UNUSEDPARAM(msg);
UNUSEDPARAM(context);
fputs(fullmsg, stderr);
}

View file

@ -23,7 +23,6 @@
* TODO: Embedded fonts
* TODO: Predictor image handling
*/
static char const rcsid[] = "$Id: pdf.c,v 1.61 2007/02/12 20:46:09 njh Exp $";
#if HAVE_CONFIG_H
#include "clamav-config.h"
@ -288,6 +287,8 @@ int pdf_findobj(struct pdf_struct *pdf)
static int filter_writen(struct pdf_struct *pdf, struct pdf_obj *obj, int fout, const char *buf, off_t len, off_t *sum)
{
UNUSEDPARAM(obj);
if (cli_checklimits("pdf", pdf->ctx, *sum, 0, 0))
return len; /* pretend it was a successful write to suppress CL_EWRITE */
@ -638,6 +639,8 @@ static int run_pdf_hooks(struct pdf_struct *pdf, enum pdf_phase phase, int fd, i
cli_ctx *ctx = pdf->ctx;
fmap_t *map;
UNUSEDPARAM(dumpid);
bc_ctx = cli_bytecode_context_alloc();
if (!bc_ctx) {
cli_errmsg("cli_pdf: can't allocate memory for bc_ctx");
@ -666,6 +669,7 @@ static int run_pdf_hooks(struct pdf_struct *pdf, enum pdf_phase phase, int fd, i
}
static void dbg_printhex(const char *msg, const char *hex, unsigned len);
static void aes_decrypt(const unsigned char *in, off_t *length, unsigned char *q, char *key, unsigned key_n, int has_iv)
{
unsigned long rk[RKLENGTH(256)];
@ -695,7 +699,7 @@ static void aes_decrypt(const unsigned char *in, off_t *length, unsigned char *q
}
cli_dbgmsg("aes_decrypt: Calling rijndaelSetupDecrypt\n");
nrounds = rijndaelSetupDecrypt(rk, key, key_n*8);
nrounds = rijndaelSetupDecrypt(rk, (const unsigned char *)key, key_n*8);
cli_dbgmsg("aes_decrypt: Beginning rijndaelDecrypt\n");
while (len >= 16) {
@ -798,7 +802,7 @@ static char *decrypt_any(struct pdf_struct *pdf, uint32_t id, const char *in, of
break;
case ENC_AESV2:
cli_dbgmsg("cli_pdf: enc is aesv2\n");
aes_decrypt(in, length, q, result, n, 1);
aes_decrypt((const unsigned char *)in, length, q, (char *)result, n, 1);
noisy_msg(pdf, "decrypted AES(v2) data\n");
@ -810,7 +814,7 @@ static char *decrypt_any(struct pdf_struct *pdf, uint32_t id, const char *in, of
return NULL;
}
aes_decrypt(in, length, q, pdf->key, pdf->keylen, 1);
aes_decrypt((const unsigned char *)in, length, q, pdf->key, pdf->keylen, 1);
noisy_msg(pdf, "decrypted AES(v3) data\n");
@ -839,7 +843,7 @@ static char *decrypt_any(struct pdf_struct *pdf, uint32_t id, const char *in, of
return NULL;
}
return q;
return (char *)q;
}
static enum enc_method get_enc_method(struct pdf_struct *pdf, struct pdf_obj *obj)
@ -885,7 +889,7 @@ static void process(struct text_norm_state *s, enum cstate *st, const char *buf,
if (*buf == ')') {
*st = CSTATE_TJ;
} else {
if (text_normalize_buffer(s, buf, 1) != 1) {
if (text_normalize_buffer(s, (const unsigned char *)buf, 1) != 1) {
cli_writen(fout, s->out, s->out_pos);
text_normalize_reset(s);
}
@ -917,7 +921,7 @@ static int pdf_scan_contents(int fd, struct pdf_struct *pdf)
return CL_ETMPFILE;
}
text_normalize_init(&s, outbuff, sizeof(outbuff));
text_normalize_init(&s, (unsigned char *)outbuff, sizeof(outbuff));
while (1) {
n = cli_readn(fd, inbuf, sizeof(inbuf));
if (n <= 0)
@ -1042,14 +1046,14 @@ int pdf_extract_obj(struct pdf_struct *pdf, struct pdf_obj *obj, uint32_t flags)
cli_dbgmsg("cli_pdf: calculated length %ld\n", length);
} else {
if (size > length+2) {
if (size > (size_t)length+2) {
cli_dbgmsg("cli_pdf: calculated length %ld < %ld\n",
length, size);
length = size;
}
}
if (orig_length && size > orig_length + 20) {
if (orig_length && size > (size_t)orig_length + 20) {
cli_dbgmsg("cli_pdf: orig length: %ld, length: %ld, size: %ld\n", orig_length, length, size);
pdfobj_flag(pdf, obj, BAD_STREAMLEN);
}
@ -1713,8 +1717,6 @@ void pdf_parseobj(struct pdf_struct *pdf, struct pdf_obj *obj)
objstate = STATE_NONE;
trailer_end = pdf_readint(dict, full_dict_length, "/H");
if (trailer_end > 0 && trailer_end < pdf->size) {
const char *enc;
trailer = trailer_end - 1024;
if (trailer < 0)
trailer = 0;
@ -2063,6 +2065,8 @@ static void check_user_password(struct pdf_struct *pdf, int R, const char *O,
struct arc4_state arc4;
unsigned password_empty = 0;
UNUSEDPARAM(oulen);
dbg_printhex("U: ", U, 32);
dbg_printhex("O: ", O, 32);
if (R == 5) {
@ -2071,7 +2075,7 @@ static void check_user_password(struct pdf_struct *pdf, int R, const char *O,
/* supplement to ISO3200, 3.5.2 Algorithm 3.11 */
/* user validation salt */
cl_sha256(U+32, 8, result2, NULL);
dbg_printhex("Computed U", result2, 32);
dbg_printhex("Computed U", (const char *)result2, 32);
if (!memcmp(result2, U, 32)) {
off_t n;
@ -2090,7 +2094,7 @@ static void check_user_password(struct pdf_struct *pdf, int R, const char *O,
return;
}
aes_decrypt(UE, &n, pdf->key, result2, 32, 0);
aes_decrypt((const unsigned char *)UE, &n, (unsigned char *)(pdf->key), (char *)result2, 32, 0);
dbg_printhex("cli_pdf: Candidate encryption key", pdf->key, pdf->keylen);
}
}
@ -2133,15 +2137,15 @@ static void check_user_password(struct pdf_struct *pdf, int R, const char *O,
return;
memcpy(pdf->key, result, pdf->keylen);
dbg_printhex("md5", result, 16);
dbg_printhex("md5", (const char *)result, 16);
dbg_printhex("Candidate encryption key", pdf->key, pdf->keylen);
/* 7.6.3.3 Algorithm 6 */
if (R == 2) {
/* 7.6.3.3 Algorithm 4 */
memcpy(data, key_padding, 32);
arc4_init(&arc4, pdf->key, pdf->keylen);
arc4_apply(&arc4, data, 32);
arc4_init(&arc4, (const uint8_t *)(pdf->key), pdf->keylen);
arc4_apply(&arc4, (uint8_t *)data, 32);
dbg_printhex("computed U (R2)", data, 32);
if (!memcmp(data, U, 32))
password_empty = 1;
@ -2159,7 +2163,7 @@ static void check_user_password(struct pdf_struct *pdf, int R, const char *O,
cl_hash_data("md5", d, 32 + pdf->fileIDlen, result, NULL);
memcpy(data, pdf->key, len);
arc4_init(&arc4, data, len);
arc4_init(&arc4, (const uint8_t *)data, len);
arc4_apply(&arc4, result, 16);
for (i=1;i<=19;i++) {
unsigned j;
@ -2167,12 +2171,12 @@ static void check_user_password(struct pdf_struct *pdf, int R, const char *O,
for (j=0;j<len;j++)
data[j] = pdf->key[j] ^ i;
arc4_init(&arc4, data, len);
arc4_init(&arc4, (const uint8_t *)data, len);
arc4_apply(&arc4, result, 16);
}
dbg_printhex("fileID", pdf->fileID, pdf->fileIDlen);
dbg_printhex("computed U (R>=3)", result, 16);
dbg_printhex("computed U (R>=3)", (const char *)result, 16);
if (!memcmp(result, U, 16))
password_empty = 1;
} else {
@ -2212,7 +2216,7 @@ static enum enc_method parse_enc_method(const char *dict, unsigned len, const ch
if (!strcmp(key, "Identity"))
return ENC_IDENTITY;
q = pdf_getdict(dict, &len, key);
q = pdf_getdict(dict, (int *)(&len), key);
if (!q)
return def;
@ -2237,7 +2241,7 @@ static enum enc_method parse_enc_method(const char *dict, unsigned len, const ch
static void pdf_handle_enc(struct pdf_struct *pdf)
{
struct pdf_obj *obj;
uint32_t len, required_flags, n, R, P, length, EM = 1, i, oulen;
uint32_t len, n, R, P, length, EM = 1, i, oulen;
char *O, *U, *UE, *StmF, *StrF, *EFF;
const char *q, *q2;
@ -2320,7 +2324,7 @@ static void pdf_handle_enc(struct pdf_struct *pdf)
StrF = pdf_readval(q, len, "/StrF");
EFF = pdf_readval(q, len, "/EFF");
n = len;
pdf->CF = pdf_getdict(q, &n, "/CF");
pdf->CF = pdf_getdict(q, (int *)(&n), "/CF");
pdf->CF_n = n;
if (StmF)
@ -2927,6 +2931,9 @@ pdf_nextobject(const char *ptr, size_t len)
#if HAVE_JSON
static void ASCIIHexDecode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
UNUSEDPARAM(obj);
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -2937,6 +2944,9 @@ static void ASCIIHexDecode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struc
#if HAVE_JSON
static void ASCII85Decode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
UNUSEDPARAM(obj);
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -2947,6 +2957,9 @@ static void ASCII85Decode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct
#if HAVE_JSON
static void EmbeddedFile_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
UNUSEDPARAM(obj);
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -2957,6 +2970,9 @@ static void EmbeddedFile_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct
#if HAVE_JSON
static void FlateDecode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
UNUSEDPARAM(obj);
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -2967,6 +2983,9 @@ static void FlateDecode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct p
#if HAVE_JSON
static void Image_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
UNUSEDPARAM(obj);
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -2977,6 +2996,9 @@ static void Image_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname
#if HAVE_JSON
static void LZWDecode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
UNUSEDPARAM(obj);
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -2987,6 +3009,9 @@ static void LZWDecode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdf
#if HAVE_JSON
static void RunLengthDecode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
UNUSEDPARAM(obj);
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -2997,6 +3022,9 @@ static void RunLengthDecode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, stru
#if HAVE_JSON
static void CCITTFaxDecode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
UNUSEDPARAM(obj);
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -3007,7 +3035,10 @@ static void CCITTFaxDecode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struc
#if HAVE_JSON
static void JBIG2Decode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
struct json_object *pdfobj, *jbig2arr, *jbig2obj;
struct json_object *pdfobj, *jbig2arr;
UNUSEDPARAM(obj);
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -3035,6 +3066,9 @@ static void JBIG2Decode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct p
#if HAVE_JSON
static void DCTDecode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
UNUSEDPARAM(obj);
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -3045,6 +3079,9 @@ static void DCTDecode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdf
#if HAVE_JSON
static void JPXDecode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
UNUSEDPARAM(obj);
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -3055,6 +3092,9 @@ static void JPXDecode_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdf
#if HAVE_JSON
static void Crypt_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
UNUSEDPARAM(obj);
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -3065,6 +3105,9 @@ static void Crypt_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname
#if HAVE_JSON
static void Standard_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
UNUSEDPARAM(obj);
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -3075,6 +3118,9 @@ static void Standard_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfn
#if HAVE_JSON
static void Sig_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
UNUSEDPARAM(obj);
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -3085,7 +3131,9 @@ static void Sig_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_a
#if HAVE_JSON
static void JavaScript_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
struct json_object *pdfobj, *jbig2arr, *jbig2obj;
struct json_object *pdfobj, *jbig2arr;
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -3113,6 +3161,9 @@ static void JavaScript_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pd
#if HAVE_JSON
static void OpenAction_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
UNUSEDPARAM(obj);
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -3123,6 +3174,9 @@ static void OpenAction_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pd
#if HAVE_JSON
static void Launch_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
UNUSEDPARAM(obj);
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -3133,6 +3187,9 @@ static void Launch_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfnam
#if HAVE_JSON
static void Page_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
UNUSEDPARAM(obj);
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -3143,6 +3200,8 @@ static void Page_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_
#if HAVE_JSON
static void Author_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -3157,6 +3216,8 @@ static void Author_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfnam
#if HAVE_JSON
static void Creator_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -3171,6 +3232,8 @@ static void Creator_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfna
#if HAVE_JSON
static void ModificationDate_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -3185,6 +3248,8 @@ static void ModificationDate_cb(struct pdf_struct *pdf, struct pdf_obj *obj, str
#if HAVE_JSON
static void CreationDate_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -3199,6 +3264,8 @@ static void CreationDate_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct
#if HAVE_JSON
static void Producer_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -3213,6 +3280,8 @@ static void Producer_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfn
#if HAVE_JSON
static void Title_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -3227,6 +3296,8 @@ static void Title_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname
#if HAVE_JSON
static void Keywords_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -3241,6 +3312,8 @@ static void Keywords_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfn
#if HAVE_JSON
static void Subject_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -3255,6 +3328,9 @@ static void Subject_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfna
#if HAVE_JSON
static void RichMedia_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
UNUSEDPARAM(obj);
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -3265,6 +3341,9 @@ static void RichMedia_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdf
#if HAVE_JSON
static void AcroForm_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
UNUSEDPARAM(obj);
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -3275,6 +3354,9 @@ static void AcroForm_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfn
#if HAVE_JSON
static void XFA_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname_action *act)
{
UNUSEDPARAM(obj);
UNUSEDPARAM(act);
if (!(pdf))
return;
@ -3288,15 +3370,18 @@ static void Pages_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname
struct pdf_array *array;
const char *objstart = (const char *)(obj->start + pdf->map);
const char *begin;
unsigned int objsz = obj_size(pdf, obj, 1);
unsigned int objsz;
unsigned long npages=0, count;
struct pdf_array_node *node;
struct pdf_dict *dict;
json_object *pdfobj;
UNUSEDPARAM(act);
if (!(pdf) || !(pdf->ctx->wrkproperty))
return;
objsz = obj_size(pdf, obj, 1);
if (!(pdf->ctx->options & CL_SCAN_FILE_PROPERTIES))
return;
@ -3310,7 +3395,7 @@ static void Pages_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfname
begin += 5;
array = pdf_parse_array(pdf, obj, objsz, begin, NULL);
array = pdf_parse_array(pdf, obj, objsz, (char *)begin, NULL);
if (!(array)) {
cli_jsonbool(pdfobj, "IncorrectPagesCount", 1);
return;
@ -3350,7 +3435,9 @@ static void Colors_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfnam
json_object *colorsobj, *pdfobj;
unsigned long ncolors;
char *start, *p1;
size_t objsz = obj_size(pdf, obj, 1);
size_t objsz;
UNUSEDPARAM(act);
if (!(pdf) || !(pdf->ctx) || !(pdf->ctx->wrkproperty))
return;
@ -3358,9 +3445,11 @@ static void Colors_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfnam
if (!(pdf->ctx->options & CL_SCAN_FILE_PROPERTIES))
return;
start = obj->start + pdf->map;
objsz = obj_size(pdf, obj, 1);
p1 = cli_memstr(start, objsz, "/Colors", 7);
start = (char *)(obj->start + pdf->map);
p1 = (char *)cli_memstr(start, objsz, "/Colors", 7);
if (!(p1))
return;
@ -3373,7 +3462,7 @@ static void Colors_cb(struct pdf_struct *pdf, struct pdf_obj *obj, struct pdfnam
while (p1 - start < objsz && isspace(p1[0]))
p1++;
if (p1 - start == objsz)
if ((size_t)(p1 - start) == objsz)
return;
ncolors = strtoul(p1, NULL, 10);

View file

@ -69,6 +69,8 @@
#include "textnorm.h"
#include "json_api.h"
char *pdf_convert_utf(char *begin, size_t sz);
char *pdf_convert_utf(char *begin, size_t sz)
{
char *res=NULL;
@ -105,7 +107,7 @@ char *pdf_convert_utf(char *begin, size_t sz)
continue;
}
iconv(cd, &p1, &inlen, &p2, &outlen);
iconv(cd, (const char **)(&p1), &inlen, &p2, &outlen);
if (outlen == sz) {
/* Decoding unsuccessful right from the start */
@ -223,10 +225,9 @@ char *pdf_parse_string(struct pdf_struct *pdf, struct pdf_obj *obj, const char *
{
const char *q = objstart;
char *p1, *p2;
size_t inlen, outlen, len, checklen;
char *buf, *outbuf, *res;
size_t len, checklen;
char *res;
int likelyutf = 0;
unsigned int i;
uint32_t objid;
/*
@ -247,22 +248,22 @@ char *pdf_parse_string(struct pdf_struct *pdf, struct pdf_obj *obj, const char *
if (objsize < strlen(str) + 3)
return NULL;
for (p1=(char *)q; (p1 - q) < objsize-checklen; p1++)
for (p1=(char *)q; (size_t)(p1 - q) < objsize-checklen; p1++)
if (!strncmp(p1, str, checklen))
break;
if (p1 - q == objsize - checklen)
if ((size_t)(p1 - q) == objsize - checklen)
return NULL;
p1 += checklen;
} else {
p1 = q;
p1 = (char *)q;
}
while ((p1 - q) < objsize && isspace(p1[0]))
while ((size_t)(p1 - q) < objsize && isspace(p1[0]))
p1++;
if ((p1 - q) == objsize)
if ((size_t)(p1 - q) == objsize)
return NULL;
/*
@ -272,10 +273,10 @@ char *pdf_parse_string(struct pdf_struct *pdf, struct pdf_obj *obj, const char *
* We should be at the start of the string
*/
p2 = q + objsize;
p2 = (char *)(q + objsize);
if (is_object_reference(p1, &p2, &objid)) {
struct pdf_obj *newobj;
char *end, *begin;
char *begin;
STATBUF sb;
uint32_t objflags;
int fd;
@ -368,15 +369,13 @@ char *pdf_parse_string(struct pdf_struct *pdf, struct pdf_obj *obj, const char *
}
if (*p1 == '<') {
size_t sz;
/* Hex string */
p2 = p1+1;
while ((p2 - q) < objsize && *p2 != '>')
while ((size_t)(p2 - q) < objsize && *p2 != '>')
p2++;
if (p2 - q == objsize) {
if ((size_t)(p2 - q) == objsize) {
return NULL;
}
@ -461,7 +460,7 @@ struct pdf_dict *pdf_parse_dict(struct pdf_struct *pdf, struct pdf_obj *obj, siz
objstart = (const char *)(obj->start + pdf->map);
if (begin < objstart || begin - objstart >= objsz - 2)
if (begin < objstart || (size_t)(begin - objstart) >= objsz - 2)
return NULL;
if (begin[0] != '<' || begin[1] != '<')
@ -469,7 +468,7 @@ struct pdf_dict *pdf_parse_dict(struct pdf_struct *pdf, struct pdf_obj *obj, siz
/* Find the end of the dictionary */
end = begin;
while (end - objstart < objsz) {
while ((size_t)(end - objstart) < objsz) {
int increment=1;
if (in_string) {
if (*end == '\\') {
@ -489,18 +488,18 @@ struct pdf_dict *pdf_parse_dict(struct pdf_struct *pdf, struct pdf_obj *obj, siz
in_string=1;
break;
case '<':
if (end - objstart <= objsz - 2 && end[1] == '<')
if ((size_t)(end - objstart) <= objsz - 2 && end[1] == '<')
ninner++;
increment=2;
break;
case '>':
if (end - objstart <= objsz - 2 && end[1] == '>')
if ((size_t)(end - objstart) <= objsz - 2 && end[1] == '>')
ninner--;
increment=2;
break;
}
if (end - objstart <= objsz - 2)
if ((size_t)(end - objstart) <= objsz - 2)
if (end[0] == '>' && end[1] == '>' && ninner == 0)
break;
@ -508,7 +507,7 @@ struct pdf_dict *pdf_parse_dict(struct pdf_struct *pdf, struct pdf_obj *obj, siz
}
/* More sanity checking */
if (end - objstart >= objsz - 2)
if ((size_t)(end - objstart) >= objsz - 2)
return NULL;
if (end[0] != '>' || end[1] != '>')
@ -609,7 +608,7 @@ struct pdf_dict *pdf_parse_dict(struct pdf_struct *pdf, struct pdf_obj *obj, siz
begin = p1+1;
break;
case '<':
if (begin - objstart < objsz - 2) {
if ((size_t)(begin - objstart) < objsz - 2) {
if (begin[1] == '<') {
dict = pdf_parse_dict(pdf, obj, objsz, begin, &p1);
begin = p1+2;
@ -717,7 +716,7 @@ struct pdf_array *pdf_parse_array(struct pdf_struct *pdf, struct pdf_obj *obj, s
struct pdf_array *res=NULL;
struct pdf_array_node *node=NULL;
const char *objstart;
char *end, *tempend;
char *end;
int in_string=0, ninner=0;
/* Sanity checking */
@ -726,7 +725,7 @@ struct pdf_array *pdf_parse_array(struct pdf_struct *pdf, struct pdf_obj *obj, s
objstart = obj->start + pdf->map;
if (begin < objstart || begin - objstart >= objsz)
if (begin < objstart || (size_t)(begin - objstart) >= objsz)
return NULL;
if (begin[0] != '[')
@ -734,7 +733,7 @@ struct pdf_array *pdf_parse_array(struct pdf_struct *pdf, struct pdf_obj *obj, s
/* Find the end of the array */
end = begin;
while (end - objstart < objsz) {
while ((size_t)(end - objstart) < objsz) {
if (in_string) {
if (*end == '\\') {
end += 2;
@ -767,7 +766,7 @@ struct pdf_array *pdf_parse_array(struct pdf_struct *pdf, struct pdf_obj *obj, s
}
/* More sanity checking */
if (end - objstart == objsz)
if ((size_t)(end - objstart) == objsz)
return NULL;
if (*end != ']')
@ -791,7 +790,7 @@ struct pdf_array *pdf_parse_array(struct pdf_struct *pdf, struct pdf_obj *obj, s
switch (begin[0]) {
case '<':
if (begin - objstart < objsz - 2 && begin[1] == '<') {
if ((size_t)(begin - objstart) < objsz - 2 && begin[1] == '<') {
dict = pdf_parse_dict(pdf, obj, objsz, begin, &begin);
begin+=2;
break;

View file

@ -21,11 +21,18 @@
#if HAVE_CONFIG_H
#include "clamav-config.h"
#endif
/*
#define _XOPEN_SOURCE 500
*/
#include <stdio.h>
#include <stdlib.h>
#if HAVE_STRING_H
#include <string.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@ -739,7 +746,6 @@ int cli_scanpe(cli_ctx *ctx)
size_t fsize;
uint32_t valign, falign, hdr_size, j;
struct cli_exe_section *exe_sections;
struct cli_matcher *mdb_sect;
char timestr[32];
struct pe_image_data_dir *dirs;
struct cli_bc_ctx *bc_ctx;
@ -748,8 +754,7 @@ int cli_scanpe(cli_ctx *ctx)
#ifdef HAVE__INTERNAL__SHA_COLLECT
int sha_collect = ctx->sha_collect;
#endif
const char * virname = NULL;
const char *archtype=NULL, *subsystem=NULL;
const char *archtype=NULL, *subsystem=NULL;
uint32_t viruses_found = 0;
#if HAVE_JSON
int toval = 0;
@ -1869,7 +1874,7 @@ int cli_scanpe(cli_ctx *ctx)
return CL_EMEM;
}
if(fmap_readn(map, dest, 0, ssize) != ssize) {
if((unsigned int)fmap_readn(map, dest, 0, ssize) != ssize) {
cli_dbgmsg("Upack: Can't read raw data of section 0\n");
free(dest);
break;
@ -1877,7 +1882,7 @@ int cli_scanpe(cli_ctx *ctx)
if(upack) memmove(dest + exe_sections[2].rva - exe_sections[0].rva, dest, ssize);
if(fmap_readn(map, dest + exe_sections[1].rva - off, exe_sections[1].uraw, exe_sections[1].ursz) != exe_sections[1].ursz) {
if((unsigned int)fmap_readn(map, dest + exe_sections[1].rva - off, exe_sections[1].uraw, exe_sections[1].ursz) != exe_sections[1].ursz) {
cli_dbgmsg("Upack: Can't read raw data of section 1\n");
free(dest);
break;
@ -2052,7 +2057,7 @@ int cli_scanpe(cli_ctx *ctx)
}
if((sections = (struct cli_exe_section *) cli_malloc((sectcnt + 1) * sizeof(struct cli_exe_section))) == NULL) {
cli_errmsg("FSG: Unable to allocate memory for sections %u\n", (sectcnt + 1) * sizeof(struct cli_exe_section));
cli_errmsg("FSG: Unable to allocate memory for sections %lu\n", (sectcnt + 1) * sizeof(struct cli_exe_section));
free(exe_sections);
return CL_EMEM;
}
@ -2156,7 +2161,7 @@ int cli_scanpe(cli_ctx *ctx)
}
if((sections = (struct cli_exe_section *) cli_malloc((sectcnt + 1) * sizeof(struct cli_exe_section))) == NULL) {
cli_errmsg("FSG: Unable to allocate memory for sections %u\n", (sectcnt + 1) * sizeof(struct cli_exe_section));
cli_errmsg("FSG: Unable to allocate memory for sections %lu\n", (sectcnt + 1) * sizeof(struct cli_exe_section));
free(exe_sections);
return CL_EMEM;
}
@ -2239,7 +2244,7 @@ int cli_scanpe(cli_ctx *ctx)
if(epbuff[1] != '\xbe' || skew <= 0 || skew > 0xfff) { /* FIXME: legit skews?? */
skew = 0;
} else if (skew > ssize) {
} else if ((unsigned int)skew > ssize) {
/* Ignore suggested skew larger than section size */
skew = 0;
} else {
@ -2395,7 +2400,7 @@ int cli_scanpe(cli_ctx *ctx)
for(i = 0 ; i < nsections; i++) {
if(exe_sections[i].raw) {
if(!exe_sections[i].rsz || fmap_readn(map, dest + exe_sections[i].rva - min, exe_sections[i].raw, exe_sections[i].ursz) != exe_sections[i].ursz) {
if(!exe_sections[i].rsz || (unsigned int)fmap_readn(map, dest + exe_sections[i].rva - min, exe_sections[i].raw, exe_sections[i].ursz) != exe_sections[i].ursz) {
free(exe_sections);
free(dest);
return CL_CLEAN;
@ -2549,7 +2554,7 @@ int cli_scanpe(cli_ctx *ctx)
for(i = 0 ; i < (unsigned int)nsections-1; i++) {
if(!exe_sections[i].rsz) continue;
if(!CLI_ISCONTAINED(src, ssize, src+exe_sections[i].rva, exe_sections[i].rsz)) break;
if(fmap_readn(map, src+exe_sections[i].rva, exe_sections[i].raw, exe_sections[i].rsz)!=exe_sections[i].rsz) break;
if((unsigned int)fmap_readn(map, src+exe_sections[i].rva, exe_sections[i].raw, exe_sections[i].rsz)!=exe_sections[i].rsz) break;
}
if(i+1!=nsections) {
cli_dbgmsg("WWpack: Probably hacked/damaged file.\n");
@ -2599,7 +2604,7 @@ int cli_scanpe(cli_ctx *ctx)
for(i = 0 ; i < (unsigned int)nsections; i++) {
if(!exe_sections[i].rsz) continue;
if(!CLI_ISCONTAINED(src, ssize, src+exe_sections[i].rva, exe_sections[i].rsz)) break;
if(fmap_readn(map, src+exe_sections[i].rva, exe_sections[i].raw, exe_sections[i].rsz)!=exe_sections[i].rsz) break;
if((unsigned int)fmap_readn(map, src+exe_sections[i].rva, exe_sections[i].raw, exe_sections[i].rsz)!=exe_sections[i].rsz) break;
}
if(i!=nsections) {
cli_dbgmsg("Aspack: Probably hacked/damaged Aspack file.\n");
@ -2743,7 +2748,7 @@ int cli_peheader(fmap_t *map, struct cli_exe_info *peinfo)
struct pe_image_optional_hdr32 opt32;
} pe_opt;
struct pe_image_section_hdr *section_hdr;
int i;
unsigned int i;
unsigned int err, pe_plus = 0;
uint32_t valign, falign, hdr_size;
size_t fsize;
@ -2939,7 +2944,7 @@ int cli_peheader(fmap_t *map, struct cli_exe_info *peinfo)
if(vinfo_sz <= 6 + 0x20 + 2 + 0x34 ||
vinfo_val_sz != 0x34 ||
memcmp(vptr+6, "V\0S\0_\0V\0E\0R\0S\0I\0O\0N\0_\0I\0N\0F\0O\0\0\0", 0x20) ||
cli_readint32(vptr + 0x28) != 0xfeef04bd) {
(unsigned int)cli_readint32(vptr + 0x28) != 0xfeef04bd) {
/* - there should be enough room for the header(6), the key "VS_VERSION_INFO"(20), the padding(2) and the value(34)
* - the value should be sizeof(fixedfileinfo)
* - the key should match
@ -3162,7 +3167,7 @@ int cli_checkfp_pe(cli_ctx *ctx, uint8_t *authsha1, stats_section_t *hashes, uin
} else { /* PE+ */
size_t readlen = sizeof(struct pe_image_optional_hdr64) - sizeof(struct pe_image_optional_hdr32);
/* read the remaining part of the header */
if(fmap_readn(map, &optional_hdr32 + 1, at, readlen) != readlen)
if((size_t)fmap_readn(map, &optional_hdr32 + 1, at, readlen) != readlen)
return CL_EFORMAT;
at += sizeof(struct pe_image_optional_hdr64) - sizeof(struct pe_image_optional_hdr32);
@ -3257,12 +3262,12 @@ int cli_checkfp_pe(cli_ctx *ctx, uint8_t *authsha1, stats_section_t *hashes, uin
return CL_EFORMAT; \
} \
if (flags & CL_CHECKFP_PE_FLAG_AUTHENTICODE && hashctx) \
cl_update_hash(hashctx, hptr, size); \
cl_update_hash(hashctx, (void *)hptr, size); \
if (isStatAble && flags & CL_CHECKFP_PE_FLAG_STATS) { \
void *md5ctx; \
md5ctx = cl_hash_init("md5"); \
if (md5ctx) { \
cl_update_hash(md5ctx, hptr, size); \
cl_update_hash(md5ctx, (void *)hptr, size); \
cl_finish_hash(md5ctx, hashes->sections[section].md5); \
} \
} \
@ -3314,7 +3319,7 @@ int cli_checkfp_pe(cli_ctx *ctx, uint8_t *authsha1, stats_section_t *hashes, uin
}
while (flags & CL_CHECKFP_PE_FLAG_AUTHENTICODE) {
if(at < fsize) {
if((size_t)at < fsize) {
hlen = fsize - at;
if(dirs[4].Size > hlen) {
if (flags & CL_CHECKFP_PE_FLAG_STATS) {

View file

@ -67,7 +67,9 @@ int cli_groupiconscan(struct ICON_ENV *icon_env, uint32_t rva);
static int groupicon_scan_cb(void *ptr, uint32_t type, uint32_t name, uint32_t lang, uint32_t rva) {
struct ICON_ENV *icon_env = ptr;
int ret = CL_CLEAN;
type = type; lang = lang; /* Prevent compiler warnings regarding unused variables */
UNUSEDPARAM(type);
UNUSEDPARAM(lang);
cli_dbgmsg("groupicon_cb: scanning group %x\n", name);
if(!icon_env->gcnt || icon_env->lastg == name) {
@ -89,8 +91,10 @@ static int parseicon(struct ICON_ENV *icon_env, uint32_t rva);
static int icon_scan_cb(void *ptr, uint32_t type, uint32_t name, uint32_t lang, uint32_t rva) {
struct ICON_ENV *icon_env = ptr;
type = type; lang = lang; /* Prevent compiler warnings regarding unused variables */
//cli_dbgmsg("icon_cb: scanning icon %x\n", name);
UNUSEDPARAM(type);
UNUSEDPARAM(lang);
UNUSEDPARAM(name);
/* scan icon */
icon_env->result = parseicon(icon_env, rva);
@ -164,7 +168,6 @@ int cli_scanicon(icon_groupset *set, uint32_t resdir_rva, cli_ctx *ctx, struct c
int cli_groupiconscan(struct ICON_ENV *icon_env, uint32_t rva)
{
/* import environment */
icon_groupset *set = icon_env->set;
uint32_t resdir_rva = icon_env->resdir_rva;
cli_ctx *ctx = icon_env->ctx;
struct cli_exe_section *exe_sections = icon_env->exe_sections;
@ -173,7 +176,7 @@ int cli_groupiconscan(struct ICON_ENV *icon_env, uint32_t rva)
int err = 0;
fmap_t *map = *ctx->fmap;
const uint8_t *grp = fmap_need_off_once(map, cli_rawaddr(rva, exe_sections, nsections, &err, map->len, hdr_size), 16);
const uint8_t *grp = fmap_need_off_once(map, cli_rawaddr(rva, exe_sections, nsections, (unsigned int *)(&err), map->len, hdr_size), 16);
if(grp && !err) {
uint32_t gsz = cli_readint32(grp + 4);
@ -191,7 +194,7 @@ int cli_groupiconscan(struct ICON_ENV *icon_env, uint32_t rva)
uint16_t id;
} *dir;
raddr = cli_rawaddr(cli_readint32(grp), exe_sections, nsections, &err, map->len, hdr_size);
raddr = cli_rawaddr(cli_readint32(grp), exe_sections, nsections, (unsigned int *)(&err), map->len, hdr_size);
cli_dbgmsg("cli_scanicon: icon group @%x\n", raddr);
grp = fmap_need_off_once(map, raddr, gsz);
if(grp && !err) {
@ -776,7 +779,7 @@ static void makebmp(const char *step, const char *tempd, int w, int h, void *dat
return;
}
for(y=h-1; y<h; y--)
for(y=h-1; y<(unsigned int)h; y--)
#if WORDS_BIGENDIAN == 0
if(!fwrite(&((unsigned int *)data)[y*w], w*4, 1, f))
break;
@ -793,7 +796,7 @@ static void makebmp(const char *step, const char *tempd, int w, int h, void *dat
}
#endif
fclose(f);
if(y<h)
if(y<(unsigned int)h)
cli_unlink(fname);
else
cli_dbgmsg("makebmp: Image %s dumped to %s\n", step, fname);
@ -1047,7 +1050,7 @@ static int getmetrics(unsigned int side, unsigned int *imagedata, struct icomtr
#ifdef USE_FLOATS
sobel = cli_malloc(side * side * sizeof(double));
if(!sobel) {
cli_errmsg("getmetrics: Unable to allocate memory for edge detection %u\n", (side * side * sizeof(double)));
cli_errmsg("getmetrics: Unable to allocate memory for edge detection %lu\n", (side * side * sizeof(double)));
free(tmp);
return CL_EMEM;
}
@ -1341,7 +1344,7 @@ static int parseicon(struct ICON_ENV *icon_env, uint32_t rva) {
return CL_SUCCESS;
}
if(READ32(bmphdr.sz) < sizeof(bmphdr)) {
if((size_t)READ32(bmphdr.sz) < sizeof(bmphdr)) {
icon_env->err_bhts++;
//cli_dbgmsg("parseicon: BMP header too small\n");
return CL_SUCCESS;

View file

@ -1193,6 +1193,8 @@ static int hash_match(const struct regex_matcher *rlist, const char *host, size_
s[hlen+plen] = '\0';
cli_dbgmsg("hash lookup for: %s\n",s);
#endif
UNUSEDPARAM(prefix_matched);
if(rlist->sha256_hashes.bm_patterns) {
const char hexchars[] = "0123456789ABCDEF";
unsigned char h[65];
@ -1204,8 +1206,8 @@ static int hash_match(const struct regex_matcher *rlist, const char *host, size_
if (!(sha256))
return CL_EMEM;
cl_update_hash(sha256, host, hlen);
cl_update_hash(sha256, path, plen);
cl_update_hash(sha256, (void *)host, hlen);
cl_update_hash(sha256, (void *)path, plen);
cl_finish_hash(sha256, sha256_dig);
for(i=0;i<32;i++) {

View file

@ -56,11 +56,6 @@ typedef unsigned long ulg;
#define CRITICAL(chunkID) (!ANCILLARY(chunkID))
#define PUBLIC(chunkID) (!PRIVATE(chunkID))
/* what the PNG, MNG and JNG magic numbers should be */
static const uch good_PNG_magic[8] = {137, 80, 78, 71, 13, 10, 26, 10};
static const uch good_MNG_magic[8] = {138, 77, 78, 71, 13, 10, 26, 10};
static const uch good_JNG_magic[8] = {139, 74, 78, 71, 13, 10, 26, 10};
/* GRR FIXME: could merge all three of these into single table (bit fields) */
/* GRR 20061203: for "isalpha()" that works even on EBCDIC machines */

View file

@ -51,13 +51,13 @@ int prtn_intxn_list_check(prtn_intxn_list_t* list, unsigned *pitxn, off_t start,
(*pitxn)--;
if (start > check_node->Start) {
if (check_node->Start+check_node->Size > start) {
if (check_node->Start+check_node->Size > (unsigned long)start) {
ret = CL_VIRUS;
break;
}
}
else if (start < check_node->Start) {
if (start+size > check_node->Start) {
if (start+size > (unsigned long)(check_node->Start)) {
ret = CL_VIRUS;
break;
}

View file

@ -348,6 +348,7 @@ int cli_initroots(struct cl_engine *engine, unsigned int options)
int i, ret;
struct cli_matcher *root;
UNUSEDPARAM(options);
for(i = 0; i < CLI_MTARGETS; i++) {
if(!engine->root[i]) {
@ -546,6 +547,7 @@ static int cli_loaddb(FILE *fs, struct cl_engine *engine, unsigned int *signo, u
int ret = 0;
struct cli_matcher *root;
UNUSEDPARAM(dbname);
if((ret = cli_initroots(engine, options)))
return ret;
@ -900,6 +902,7 @@ static int cli_loadndb(FILE *fs, struct cl_engine *engine, unsigned int *signo,
unsigned short target;
unsigned int phish = options & CL_DB_PHISHING;
UNUSEDPARAM(dbname);
if((ret = cli_initroots(engine, options)))
return ret;
@ -1243,6 +1246,8 @@ static int load_oneldb(char *buffer, int chkpua, struct cl_engine *engine, unsig
uint32_t lsigid[2];
int ret;
UNUSEDPARAM(dbname);
tokens_count = cli_strtokenize(buffer, ';', LDB_TOKENS + 1, (const char **) tokens);
if(tokens_count < 4) {
return CL_EMALFDB;
@ -1850,6 +1855,8 @@ static int cli_loadign(FILE *fs, struct cl_engine *engine, unsigned int options,
struct cli_bm_patt *new;
int ret = CL_SUCCESS;
UNUSEDPARAM(options);
if(!engine->ignored) {
engine->ignored = (struct cli_matcher *) mpool_calloc(engine->mempool, 1, sizeof(struct cli_matcher));
if(!engine->ignored)
@ -2000,7 +2007,7 @@ static int cli_loadhash(FILE *fs, struct cl_engine *engine, unsigned int *signo,
continue;
if(tokens_count == MD5_TOKENS) {
int max_fl = atoi(tokens[MD5_TOKENS - 1]);
if(cl_retflevel() > max_fl)
if(cl_retflevel() > (unsigned int)max_fl)
continue;
}
}
@ -2085,6 +2092,7 @@ static int cli_loadmd(FILE *fs, struct cl_engine *engine, unsigned int *signo, i
int ret = CL_SUCCESS;
struct cli_cdb *new;
UNUSEDPARAM(dbname);
if(engine->ignored)
if(!(buffer_cpy = cli_malloc(FILEBUFF))) {
@ -2418,12 +2426,11 @@ static int cli_loadcdb(FILE *fs, struct cl_engine *engine, unsigned int *signo,
static int cli_loadcrt(FILE *fs, struct cl_engine *engine, struct cli_dbio *dbio) {
char buffer[FILEBUFF];
char *tokens[CRT_TOKENS+1];
size_t line=0, tokens_count, i, j;
size_t line=0, tokens_count;
cli_crt ca;
int ret=CL_SUCCESS;
char *subject=NULL, *pubkey=NULL, *exponent=NULL, *serial=NULL;
char *subject=NULL, *pubkey=NULL, *serial=NULL;
const uint8_t exp[] = "\x01\x00\x01";
char c;
cli_crt_init(&ca);
memset(ca.issuer, 0xca, sizeof(ca.issuer));
@ -2512,7 +2519,7 @@ static int cli_loadcrt(FILE *fs, struct cl_engine *engine, struct cli_dbio *dbio
}
memcpy(ca.subject, subject, sizeof(ca.subject));
if (mp_read_unsigned_bin(&(ca.n), pubkey, strlen(tokens[4])/2) || mp_read_unsigned_bin(&(ca.e), exp, sizeof(exp)-1)) {
if (mp_read_unsigned_bin(&(ca.n), (const unsigned char *)pubkey, strlen(tokens[4])/2) || mp_read_unsigned_bin(&(ca.e), exp, sizeof(exp)-1)) {
cli_errmsg("cli_loadcrt: line %u: Cannot convert exponent to binary data\n", (unsigned int)line);
ret = CL_EMALFDB;
goto end;
@ -2587,6 +2594,9 @@ end:
static int cli_loadmscat(FILE *fs, const char *dbname, struct cl_engine *engine, unsigned int options, struct cli_dbio *dbio) {
fmap_t *map;
UNUSEDPARAM(options);
UNUSEDPARAM(dbio);
if(!(map = fmap(fileno(fs), 0, 0))) {
cli_dbgmsg("Can't map cat: %s\n", dbname);
return 0;

View file

@ -448,12 +448,12 @@ dissect(struct match *m, char *start, char *stop, sopno startst, sopno stopst)
break;
case OLPAREN:
i = OPND(m->g->strip[ss]);
assert(0 < i && i <= m->g->nsub);
assert(0 < i && (size_t)i <= m->g->nsub);
m->pmatch[i].rm_so = sp - m->offp;
break;
case ORPAREN:
i = OPND(m->g->strip[ss]);
assert(0 < i && i <= m->g->nsub);
assert(0 < i && (size_t)i <= m->g->nsub);
m->pmatch[i].rm_eo = sp - m->offp;
break;
default: /* uh oh */
@ -572,14 +572,14 @@ backref(struct match *m, char *start, char *stop, sopno startst, sopno stopst,
switch (OP(s)) {
case OBACK_: /* the vilest depths */
i = OPND(s);
assert(0 < i && i <= m->g->nsub);
assert(0 < i && (size_t)i <= m->g->nsub);
if (m->pmatch[i].rm_eo == -1)
return(NULL);
assert(m->pmatch[i].rm_so != -1);
len = m->pmatch[i].rm_eo - m->pmatch[i].rm_so;
if (len == 0 && rec++ > MAX_RECURSION)
return(NULL);
assert(stop - m->beginp >= len);
assert((size_t)(stop - m->beginp) >= len);
if (sp > stop - len)
return(NULL); /* not enough left to match */
ssp = m->offp + m->pmatch[i].rm_so;
@ -635,7 +635,7 @@ backref(struct match *m, char *start, char *stop, sopno startst, sopno stopst,
break;
case OLPAREN: /* must undo assignment if rest fails */
i = OPND(s);
assert(0 < i && i <= m->g->nsub);
assert(0 < i && (size_t)i <= m->g->nsub);
offsave = m->pmatch[i].rm_so;
m->pmatch[i].rm_so = sp - m->offp;
dp = backref(m, sp, stop, ss+1, stopst, lev, rec);
@ -646,7 +646,7 @@ backref(struct match *m, char *start, char *stop, sopno startst, sopno stopst,
break;
case ORPAREN: /* must undo assignment if rest fails */
i = OPND(s);
assert(0 < i && i <= m->g->nsub);
assert(0 < i && (size_t)i <= m->g->nsub);
offsave = m->pmatch[i].rm_eo;
m->pmatch[i].rm_eo = sp - m->offp;
dp = backref(m, sp, stop, ss+1, stopst, lev, rec);

View file

@ -553,7 +553,7 @@ p_simp_re(struct parse *p,
i = (c&~BACKSL) - '0';
assert(i < NPAREN);
if (p->pend[i] != 0) {
assert(i <= p->g->nsub);
assert((size_t)i <= p->g->nsub);
EMIT(OBACK_, i);
assert(p->pbegin[i] != 0);
assert(OP(p->strip[p->pbegin[i]]) == OLPAREN);
@ -1196,6 +1196,7 @@ mcadd( struct parse *p, cset *cs, const char *cp)
static void
mcinvert(struct parse *p, cset *cs)
{
UNUSEDPARAM(p);
assert(cs->multis == NULL); /* xxx */
}
@ -1209,6 +1210,7 @@ mcinvert(struct parse *p, cset *cs)
static void
mccase(struct parse *p, cset *cs)
{
UNUSEDPARAM(p);
assert(cs->multis == NULL); /* xxx */
}

View file

@ -157,7 +157,7 @@ cli_regexec(const regex_t *preg, const char *string, size_t nmatch,
return(REG_BADPAT);
eflags = GOODFLAGS(eflags);
if (g->nstates <= CHAR_BIT*sizeof(states1) && !(eflags&REG_LARGE))
if ((unsigned long)(g->nstates) <= CHAR_BIT*sizeof(states1) && !(eflags&REG_LARGE))
return(smatcher(g, (char *)string, nmatch, pmatch, eflags));
else
return(lmatcher(g, (char *)string, nmatch, pmatch, eflags));

View file

@ -704,6 +704,9 @@ static const u32 rcon[] =
(ciphertext)[2] = (u8)((st) >> 8); \
(ciphertext)[3] = (u8)(st); }
int rijndaelSetupEncrypt(u32 *rk, const u8 *key, int keybits);
void rijndaelEncrypt(const u32 *rk, int nrounds, const u8 plaintext[16], u8 ciphertext[16]);
/**
* Expand the cipher key into the encryption key schedule.
*

View file

@ -206,7 +206,7 @@ static char *getsistring(fmap_t *map, uint32_t ptr, uint32_t len) {
cli_dbgmsg("SIS: OOM\n");
return NULL;
}
if (fmap_readn(map, name, ptr, len) != len) {
if ((uint32_t)fmap_readn(map, name, ptr, len) != len) {
cli_dbgmsg("SIS: Unable to read string\n");
free(name);
return NULL;
@ -310,7 +310,7 @@ static int real_scansis(cli_ctx *ctx, const char *tmpd) {
return CL_CLEAN;
}
for (i = 0; i< sis.langs; i++)
alangs[i]=EC16(llangs[i])<MAXLANG ? sislangs[EC16(llangs[i])] : sislangs[0];
alangs[i]=(size_t)EC16(llangs[i])<MAXLANG ? sislangs[EC16(llangs[i])] : sislangs[0];
if (!sis.pnames) {
cli_dbgmsg("SIS: Application without a name?\n");
@ -376,7 +376,6 @@ static int real_scansis(cli_ctx *ctx, const char *tmpd) {
const char *sftype;
uint32_t *ptrs, *lens, *olens;
char *fn;
long fpos;
GETD(ftype);
GETD(options);
@ -717,7 +716,7 @@ static int real_scansis9x(cli_ctx *ctx, const char *tmpd) {
if (!(src=cli_malloc(ALIGN4(s->fsize[s->level])))) break;
len = ALIGN4(s->fsize[s->level]);
if (fmap_readn(s->map, src, s->pos, len) != len) {
if ((uint32_t)fmap_readn(s->map, src, s->pos, len) != len) {
free(src);
break;
}

View file

@ -578,6 +578,8 @@ char *clamav_stats_get_hostid(void *cbdata)
size_t bufsz, i;
char *buf;
UNUSEDPARAM(cbdata);
#if HAVE_SYSCTLBYNAME
/*
* FreeBSD provides a handy-dandy sysctl for grabbing the system's HostID. In a jail that

View file

@ -40,6 +40,10 @@
#define JSON_BUFSZ 512
#define SAMPLE_PREFIX "sample_"
char *hex_encode(char *buf, char *data, size_t len);
char *ensure_bufsize(char *buf, size_t *oldsize, size_t used, size_t additional);
char *export_stats_to_json(struct cl_engine *engine, cli_intel_t *intel);
char *hex_encode(char *buf, char *data, size_t len)
{
size_t i;
@ -78,7 +82,7 @@ char *ensure_bufsize(char *buf, size_t *oldsize, size_t used, size_t additional)
char *export_stats_to_json(struct cl_engine *engine, cli_intel_t *intel)
{
char *buf=NULL, *p, *hostid, md5[33];
char *buf=NULL, *hostid, md5[33];
cli_flagged_sample_t *sample;
size_t bufsz, curused, i, j;

View file

@ -146,8 +146,8 @@ static int scancws(cli_ctx *ctx, struct swf_file_hdr *hdr)
}
stream.avail_in = 0;
stream.next_in = inbuff;
stream.next_out = outbuff;
stream.next_in = (Bytef *)inbuff;
stream.next_out = (Bytef *)outbuff;
stream.zalloc = (alloc_func) NULL;
stream.zfree = (free_func) NULL;
stream.opaque = (voidpf) 0;
@ -167,7 +167,7 @@ static int scancws(cli_ctx *ctx, struct swf_file_hdr *hdr)
do {
if(stream.avail_in == 0) {
stream.next_in = inbuff;
stream.next_in = (Bytef *)inbuff;
ret = fmap_readn(map, inbuff, offset, FILEBUFF);
if(ret < 0) {
cli_errmsg("scancws: Error reading SWF file\n");
@ -201,7 +201,7 @@ static int scancws(cli_ctx *ctx, struct swf_file_hdr *hdr)
}
outsize += count;
}
stream.next_out = outbuff;
stream.next_out = (Bytef *)outbuff;
stream.avail_out = FILEBUFF;
} while(zret == Z_OK);

View file

@ -86,8 +86,6 @@
*
*/
static char const rcsid[] = "$Id: text.c,v 1.25 2007/02/12 20:46:09 njh Exp $";
#if HAVE_CONFIG_H
#include "clamav-config.h"
#endif

View file

@ -22,8 +22,6 @@
#include "clamav-config.h"
#endif
static char const rcsid[] = "$Id: tnef.c,v 1.41 2007/02/12 22:22:27 njh Exp $";
#include <stdio.h>
#include <fcntl.h>
@ -68,8 +66,6 @@ cli_tnef(const char *dir, cli_ctx *ctx)
fileblob *fb;
int ret, alldone;
off_t fsize, pos = 0;
STATBUF statb;
fsize = ctx->fmap[0]->len;
@ -204,7 +200,6 @@ cli_tnef(const char *dir, cli_ctx *ctx)
static int
tnef_message(fmap_t *map, off_t *pos, uint16_t type, uint16_t tag, int32_t length, off_t fsize)
{
uint16_t i16;
off_t offset;
#ifdef CL_DEBUG
uint32_t i32;
@ -252,7 +247,7 @@ tnef_message(fmap_t *map, off_t *pos, uint16_t type, uint16_t tag, int32_t lengt
cli_errmsg("tnef_message: Unable to allocate memory for string\n");
return -1;
}
if(fmap_readn(map, string, *pos, (uint32_t)length) != (uint32_t)length) {
if((uint32_t)fmap_readn(map, string, *pos, (uint32_t)length) != (uint32_t)length) {
free(string);
return -1;
}
@ -285,7 +280,6 @@ static int
tnef_attachment(fmap_t *map, off_t *pos, uint16_t type, uint16_t tag, int32_t length, const char *dir, fileblob **fbref, off_t fsize)
{
uint32_t todo;
uint16_t i16;
off_t offset;
char *string;
@ -303,7 +297,7 @@ tnef_attachment(fmap_t *map, off_t *pos, uint16_t type, uint16_t tag, int32_t le
cli_errmsg("tnef_attachment: Unable to allocate memory for string\n");
return -1;
}
if(fmap_readn(map, string, *pos, (uint32_t)length) != (uint32_t)length) {
if((uint32_t)fmap_readn(map, string, *pos, (uint32_t)length) != (uint32_t)length) {
free(string);
return -1;
}

View file

@ -9,6 +9,8 @@
*/
#include "bignum_fast.h"
int fp_radix_size(fp_int *a, int radix, int *size);
int fp_radix_size(fp_int *a, int radix, int *size)
{
int digs;

View file

@ -273,7 +273,7 @@ static int make_table(arj_decode_t *decode_data, int nchar, unsigned char *bitle
if (i != (unsigned short) (1 << 16)) {
k = 1 << tablebits;
while (i != k) {
if (i >= tablesize) {
if (i >= (unsigned int)tablesize) {
cli_dbgmsg("UNARJ: bounds exceeded\n");
decode_data->status = CL_EUNPACK;
return CL_EUNPACK;
@ -588,7 +588,7 @@ static int decode(arj_metadata_t *metadata)
cli_dbgmsg("UNARJ: bounds exceeded - probably a corrupted file.\n");
break;
}
if (out_ptr > i && out_ptr < DDICSIZ - MAXMATCH - 1) {
if (out_ptr > (uint32_t)i && out_ptr < DDICSIZ - MAXMATCH - 1) {
while ((--j >= 0) && (i < DDICSIZ) && (out_ptr < DDICSIZ)) {
decode_data.text[out_ptr++] = decode_data.text[i++];
}
@ -779,7 +779,7 @@ static int arj_unstore(arj_metadata_t *metadata, int ofd, uint32_t len)
return CL_EFORMAT;
}
metadata->offset += count;
if (cli_writen(ofd, data, count) != count) {
if ((size_t)cli_writen(ofd, data, count) != count) {
/* File writing problem */
return CL_EWRITE;
}
@ -807,7 +807,6 @@ static int is_arj_archive(arj_metadata_t *metadata)
static int arj_read_main_header(arj_metadata_t *metadata)
{
uint16_t header_size, count;
uint32_t crc;
arj_main_hdr_t main_hdr;
const char *filename, *comment;
off_t header_offset;
@ -984,6 +983,7 @@ static int arj_read_file_header(arj_metadata_t *metadata)
int cli_unarj_open(fmap_t *map, const char *dirname, arj_metadata_t *metadata, size_t off)
{
UNUSEDPARAM(dirname);
cli_dbgmsg("in cli_unarj_open\n");
metadata->map = map;
metadata->offset = off;
@ -1014,7 +1014,6 @@ int cli_unarj_prepare_file(const char *dirname, arj_metadata_t *metadata)
int cli_unarj_extract_file(const char *dirname, arj_metadata_t *metadata)
{
off_t offset;
int ret = CL_SUCCESS;
char filename[1024];

View file

@ -18,8 +18,6 @@
* MA 02110-1301, USA.
*/
static char const rcsid[] = "$Id: untar.c,v 1.35 2007/02/12 20:46:09 njh Exp $";
#if HAVE_CONFIG_H
#include "clamav-config.h"
#endif
@ -316,7 +314,7 @@ cli_untar(const char *dir, unsigned int posix, cli_ctx *ctx)
char err[128];
nbytes = size>512? 512:size;
if (nread && nread < nbytes)
if (nread && nread < (size_t)nbytes)
nbytes = nread;
if (limitnear > 0) {

View file

@ -501,7 +501,7 @@ int cli_unzip(cli_ctx *ctx) {
cli_dbgmsg("in cli_unzip\n");
fsize = (uint32_t)map->len;
if(sizeof(off_t)!=sizeof(uint32_t) && (off_t)fsize!=map->len) {
if(sizeof(off_t)!=sizeof(uint32_t) && (size_t)fsize!=map->len) {
cli_dbgmsg("cli_unzip: file too big\n");
return CL_CLEAN;
}
@ -585,7 +585,7 @@ int unzip_single_internal(cli_ctx *ctx, off_t lhoffl, zip_cb zcb)
cli_dbgmsg("in cli_unzip_single\n");
fsize = (uint32_t)(map->len - lhoffl);
if (lhoffl<0 || lhoffl>map->len || (sizeof(off_t)!=sizeof(uint32_t) && (off_t)fsize!=map->len - lhoffl)) {
if (lhoffl<0 || (size_t)lhoffl>map->len || (sizeof(off_t)!=sizeof(uint32_t) && (size_t)fsize!=map->len - lhoffl)) {
cli_dbgmsg("cli_unzip: bad offset\n");
return CL_CLEAN;
}
@ -623,7 +623,7 @@ int unzip_search(cli_ctx *ctx, const char *name, size_t nlen, uint32_t *loff)
map = *ctx->fmap;
fsize = map->len;
if(sizeof(off_t)!=sizeof(uint32_t) && (off_t)fsize!=map->len) {
if(sizeof(off_t)!=sizeof(uint32_t) && fsize!=map->len) {
cli_dbgmsg("unzip_search: file too big\n");
return CL_CLEAN;
}
@ -661,7 +661,7 @@ int unzip_search(cli_ctx *ctx, const char *name, size_t nlen, uint32_t *loff)
ret=CL_EMAXFILES;
}
#if HAVE_JSON
if (cli_json_timeout_cycle_check(ctx, &toval) != CL_SUCCESS) {
if (cli_json_timeout_cycle_check(ctx, (int *)(&toval)) != CL_SUCCESS) {
return CL_ETIMEOUT;
}
#endif

View file

@ -31,6 +31,7 @@ typedef int (*zip_cb)(int fd, cli_ctx *ctx);
#include "others.h"
int cli_unzip(cli_ctx *);
int cli_unzip_single_internal(cli_ctx *, off_t, zip_cb);
int unzip_single_internal(cli_ctx *ctx, off_t lhoffl, zip_cb zcb);
int cli_unzip_single(cli_ctx *, off_t);
int unzip_search(cli_ctx *, const char *, size_t, uint32_t *);

View file

@ -318,7 +318,7 @@ int unupack(int upack, char *dest, uint32_t dsize, char *buff, uint32_t vma, uin
save1 = cli_readint32(loc_esi); /* loc_eax = 0x400 */
loc_esi += 4;
for (j=0; j<count; j++, loc_edi+=4) /* checked above */
for (j=0; (uint32_t)j<count; j++, loc_edi+=4) /* checked above */
cli_writeint32(loc_edi, (save1));
if (!CLI_ISCONTAINED(dest, dsize, (loc_esi+0x10), 4))
@ -363,7 +363,7 @@ int unupack(int upack, char *dest, uint32_t dsize, char *buff, uint32_t vma, uin
for (j=0; j<4; j++, loc_edi+=4)
cli_writeint32(loc_edi, (1));
for (j=0; j<count; j++, loc_edi+=4)
for (j=0; (uint32_t)j<count; j++, loc_edi+=4)
cli_writeint32(loc_edi, 0x400);
loc_edi = dest + cli_readint32(loc_esi) - base; /* read checked above */

View file

@ -18,8 +18,6 @@
* MA 02110-1301, USA.
*/
static char const rcsid[] = "$Id: uuencode.c,v 1.8 2006/12/11 11:55:11 njh Exp $";
#include "clamav.h"
#if HAVE_CONFIG_H

View file

@ -244,7 +244,7 @@ int wwunpack(uint8_t *exe, uint32_t exesz, uint8_t *wwsect, struct cli_exe_secti
}
memset(structs, 0, 0x28);
error = cli_writen(desc, exe, exesz)!=exesz;
error = (uint32_t)cli_writen(desc, exe, exesz)!=exesz;
}
return error;
}

View file

@ -264,7 +264,7 @@ void submit_post(const char *host, const char *port, const char *method, const c
cli_dbgmsg("stats - Connected to %s:%s\n", host, port);
if (send(sockfd, buf, strlen(buf), 0) != strlen(buf)) {
if ((size_t)send(sockfd, buf, strlen(buf), 0) != (size_t)strlen(buf)) {
closesocket(sockfd);
free(buf);
return;

View file

@ -417,12 +417,14 @@ int cli_scanxar(cli_ctx *ctx)
fmap_t *map = *ctx->fmap;
long length, offset, size, at;
int encoding;
z_stream strm = {0};
z_stream strm;
char *toc, *tmpname;
xmlTextReaderPtr reader = NULL;
int a_hash, e_hash;
unsigned char *a_cksum = NULL, *e_cksum = NULL;
memset(&strm, 0x00, sizeof(z_stream));
/* retrieve xar header */
if (fmap_readn(*ctx->fmap, &hdr, 0, sizeof(hdr)) != sizeof(hdr)) {
cli_dbgmsg("cli_scanxar: Invalid header, too short.\n");
@ -572,7 +574,7 @@ int cli_scanxar(cli_ctx *ctx)
break;
}
while (at < map->len && at < offset+hdr.toc_length_compressed+hdr.size+length) {
while ((size_t)at < map->len && (unsigned long)at < offset+hdr.toc_length_compressed+hdr.size+length) {
unsigned long avail_in;
void * next_in;
unsigned int bytes = MIN(map->len - at, map->pgsz);
@ -672,7 +674,7 @@ int cli_scanxar(cli_ctx *ctx)
at += CLI_LZMA_HDR_SIZE;
in_remaining -= CLI_LZMA_HDR_SIZE;
while (at < map->len && at < offset+hdr.toc_length_compressed+hdr.size+length) {
while ((size_t)at < map->len && (unsigned long)at < offset+hdr.toc_length_compressed+hdr.size+length) {
SizeT avail_in;
SizeT avail_out;
void * next_in;
@ -751,7 +753,7 @@ int cli_scanxar(cli_ctx *ctx)
unsigned long write_len;
if (ctx->engine->maxfilesize)
write_len = MIN(ctx->engine->maxfilesize, length);
write_len = MIN((size_t)(ctx->engine->maxfilesize), (size_t)length);
else
write_len = length;

View file

@ -26,10 +26,13 @@
#include "7z/XzCrc64.h"
#include "xz_iface.h"
void *__xz_wrap_alloc(void *unused, size_t size);
void __xz_wrap_free(void *unused, void *freeme);
void *__xz_wrap_alloc(void *unused, size_t size) {
UNUSEDPARAM(unused);
if(!size || size > CLI_MAX_ALLOCATION)
return NULL;
unused = unused;
if(!size || size > CLI_MAX_ALLOCATION) {
cli_dbgmsg("xz_iface: Attempt to allocate %lu bytes exceeds CLI_MAX_ALLOCATION.\n",
(unsigned long int) size);
@ -38,7 +41,7 @@ void *__xz_wrap_alloc(void *unused, size_t size) {
return cli_malloc(size);
}
void __xz_wrap_free(void *unused, void *freeme) {
unused = unused;
UNUSEDPARAM(unused);
free(freeme);
}