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 6 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 @@ -1966,7 +1966,7 @@ int main(int argc, char **argv)
ret = 0;
goto fin;
}
for (i = 0; i < num_images; i++) {
for (size_t i = 0; i < num_images; i++) {
Eharve14 marked this conversation as resolved.
Show resolved Hide resolved
dirptr->filename[i] = dirptr->filename_buf + i * OPJ_PATH_LEN;
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/bin/jp2/opj_decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -1365,9 +1365,7 @@ int main(int argc, char **argv)

/* Initialize reading of directory */
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 @@ -1386,7 +1384,7 @@ int main(int argc, char **argv)
failed = 1;
goto fin;
}
for (it_image = 0; it_image < num_images; it_image++) {
for (size_t it_image = 0; it_image < num_images; it_image++) {
dirptr->filename[it_image] = dirptr->filename_buf + it_image * OPJ_PATH_LEN;
}

Expand Down
4 changes: 1 addition & 3 deletions src/bin/jp2/opj_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,6 @@ int main(int argc, char *argv[])

/* Initialize reading of directory */
if (img_fol.set_imgdir == 1) {
int it_image;
num_images = get_num_images(img_fol.imgdirpath);

dirptr = (dircnt_t*)malloc(sizeof(dircnt_t));
Expand All @@ -528,14 +527,13 @@ int main(int argc, char *argv[])
goto fails;
}

for (it_image = 0; it_image < num_images; it_image++) {
for (size_t it_image = 0; it_image < num_images; it_image++) {
dirptr->filename[it_image] = dirptr->filename_buf + 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