Skip to content

Commit

Permalink
Fix GitHub code scan issues
Browse files Browse the repository at this point in the history
  • Loading branch information
micahsnyder committed Mar 15, 2024
1 parent 405829e commit 0e5d3f9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion libclamav/bytecode_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion libclamav/hashtab.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion libclamav/nsis/bzlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions libclamav/pe_icons.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 0e5d3f9

Please sign in to comment.