Skip to content

Commit

Permalink
Avoid overflow in multiplications in utilities related to big number …
Browse files Browse the repository at this point in the history
…of files in a directory (CVE-2021-29338)  (#1396)
  • Loading branch information
Eharve14 authored Jan 13, 2022
1 parent 79c7d7a commit 1daaa0b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/bin/jp2/opj_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -1967,7 +1967,7 @@ int main(int argc, char **argv)
goto fin;
}
for (i = 0; i < num_images; i++) {
dirptr->filename[i] = dirptr->filename_buf + i * OPJ_PATH_LEN;
dirptr->filename[i] = dirptr->filename_buf + (size_t)i * OPJ_PATH_LEN;
}
}
if (load_images(dirptr, img_fol.imgdirpath) == 1) {
Expand Down
4 changes: 2 additions & 2 deletions src/bin/jp2/opj_decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,6 @@ int main(int argc, char **argv)
if (img_fol.set_imgdir == 1) {
int it_image;
num_images = get_num_images(img_fol.imgdirpath);

dirptr = (dircnt_t*)calloc(1, sizeof(dircnt_t));
if (!dirptr) {
destroy_parameters(&parameters);
Expand All @@ -1387,7 +1386,8 @@ int main(int argc, char **argv)
goto fin;
}
for (it_image = 0; it_image < num_images; it_image++) {
dirptr->filename[it_image] = dirptr->filename_buf + it_image * OPJ_PATH_LEN;
dirptr->filename[it_image] = dirptr->filename_buf + (size_t)it_image *
OPJ_PATH_LEN;
}

if (load_images(dirptr, img_fol.imgdirpath) == 1) {
Expand Down
4 changes: 2 additions & 2 deletions src/bin/jp2/opj_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -529,13 +529,13 @@ int main(int argc, char *argv[])
}

for (it_image = 0; it_image < num_images; it_image++) {
dirptr->filename[it_image] = dirptr->filename_buf + it_image * OPJ_PATH_LEN;
dirptr->filename[it_image] = dirptr->filename_buf + (size_t)it_image *
OPJ_PATH_LEN;
}

if (load_images(dirptr, img_fol.imgdirpath) == 1) {
goto fails;
}

if (num_images == 0) {
fprintf(stdout, "Folder is empty\n");
goto fails;
Expand Down

0 comments on commit 1daaa0b

Please sign in to comment.