From 481235c78770f4804bc050eaee76b1d38e42b7ff Mon Sep 17 00:00:00 2001 From: Micah Snyder Date: Tue, 9 Jan 2024 19:40:22 -0500 Subject: [PATCH] Fix GitHub code scan issues --- libclamav/bytecode_api.c | 2 +- libclamav/hashtab.c | 2 +- libclamav/nsis/bzlib.c | 2 +- libclamav/pe_icons.c | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libclamav/bytecode_api.c b/libclamav/bytecode_api.c index c597b09869..1809fe12d6 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 (%zu 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 32600dcbca..7317b0b464 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 18c0994686..149c08c3eb 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;