diff --git a/libclamav/bytecode_api.c b/libclamav/bytecode_api.c index 9d136387a3..5a77fb0aa1 100644 --- a/libclamav/bytecode_api.c +++ b/libclamav/bytecode_api.c @@ -472,7 +472,7 @@ uint8_t *cli_bcapi_malloc(struct cli_bc_ctx *ctx, uint32_t size) } if (0 == size || size > CLI_MAX_ALLOCATION) { - cli_warnmsg("cli_bcapi_malloc(): File or section is too large to scan (%u bytes). For your safety, ClamAV limits how much memory an operation can allocate to %d bytes\n", + cli_warnmsg("cli_bcapi_malloc(): File or section is too large to scan (" STDu32 " bytes). For your safety, ClamAV limits how much memory an operation can allocate to %d bytes\n", size, CLI_MAX_ALLOCATION); v = NULL; } else { diff --git a/libclamav/hashtab.c b/libclamav/hashtab.c index fdc2d6cbf6..75213217eb 100644 --- a/libclamav/hashtab.c +++ b/libclamav/hashtab.c @@ -889,7 +889,7 @@ cl_error_t cli_map_addkey(struct cli_map *m, const void *key, int32_t keysize) if (m->valuesize) { void *v; - v = cli_max_realloc(m->u.sized_values, n * m->valuesize); + v = cli_max_realloc(m->u.sized_values, (size_t)n * (size_t)m->valuesize); if (!v) { return CL_EMEM; } diff --git a/libclamav/nsis/bzlib.c b/libclamav/nsis/bzlib.c index 0e14088f3b..b67d97a83b 100644 --- a/libclamav/nsis/bzlib.c +++ b/libclamav/nsis/bzlib.c @@ -990,7 +990,7 @@ int bz_config_ok ( void ) static void* default_bzalloc ( void* opaque, Int32 items, Int32 size ) { - void* v = cli_max_malloc ( items * size ); + void* v = cli_max_malloc ( (size_t)items * (size_t)size ); UNUSEDPARAM(opaque); return v; } diff --git a/libclamav/pe_icons.c b/libclamav/pe_icons.c index 5feb7b97cd..023b346a6b 100644 --- a/libclamav/pe_icons.c +++ b/libclamav/pe_icons.c @@ -901,7 +901,7 @@ static int getmetrics(unsigned int side, unsigned int *imagedata, struct icomtr unsigned int edge_avg[6], edge_x[6] = {0, 0, 0, 0, 0, 0}, edge_y[6] = {0, 0, 0, 0, 0, 0}, noedge_avg[6], noedge_x[6] = {0, 0, 0, 0, 0, 0}, noedge_y[6] = {0, 0, 0, 0, 0, 0}; double *sobel; - if (!(tmp = cli_max_malloc(side * side * 4 * 2))) { + if (!(tmp = cli_max_malloc((size_t)side * (size_t)side * 4 * 2))) { cli_errmsg("getmetrics: Unable to allocate memory for tmp %u\n", (side * side * 4 * 2)); return CL_EMEM; } @@ -1067,7 +1067,7 @@ static int getmetrics(unsigned int side, unsigned int *imagedata, struct icomtr /* Sobel 1 - gradients */ i = 0; #ifdef USE_FLOATS - sobel = cli_max_malloc(side * side * sizeof(double)); + sobel = cli_max_malloc((size_t)side * (size_t)side * sizeof(double)); if (!sobel) { cli_errmsg("getmetrics: Unable to allocate memory for edge detection %llu\n", (long long unsigned)(side * side * sizeof(double))); free(tmp); @@ -1457,7 +1457,7 @@ static int parseicon(struct ICON_ENV *icon_env, uint32_t rva) fmap_unneed_ptr(map, palette, (1 << depth) * sizeof(int)); return CL_SUCCESS; } - if (!(imagedata = cli_max_malloc(width * height * sizeof(*imagedata)))) { + if (!(imagedata = cli_max_malloc((size_t)width * (size_t)height * sizeof(*imagedata)))) { if (palette) fmap_unneed_ptr(map, palette, (1 << depth) * sizeof(int)); return CL_SUCCESS;