Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added overflow check for CVE-2021-29338 #1396

Merged
merged 15 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 *
rouault marked this conversation as resolved.
Show resolved Hide resolved
OPJ_PATH_LEN;
rouault marked this conversation as resolved.
Show resolved Hide resolved
}

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

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