Revised to catch negitive values of num_images

This commit is contained in:
Eharve14 2022-01-13 12:04:59 -05:00
parent d8fe12641e
commit 968cf54a95
3 changed files with 3 additions and 3 deletions

View File

@ -1957,7 +1957,7 @@ int main(int argc, char **argv)
/* Read directory if necessary */
if (img_fol.set_imgdir == 1) {
num_images = get_num_images(img_fol.imgdirpath);
if((num_images > SIZE_MAX/(OPJ_PATH_LEN * sizeof(char)))){
if(num_images > SIZE_MAX/(OPJ_PATH_LEN * sizeof(char)) || num_images < 0){
fprintf(stdout, "Max images exceeded\n");
ret = 0;
goto fin;

View File

@ -1367,7 +1367,7 @@ int main(int argc, char **argv)
if (img_fol.set_imgdir == 1) {
int it_image;
num_images = get_num_images(img_fol.imgdirpath);
if( num_images > SIZE_MAX/(sizeof(char)* OPJ_PATH_LEN)){
if( num_images > SIZE_MAX/(sizeof(char)* OPJ_PATH_LEN) || num_images < 0){
fprintf(stderr, "Max number of images exceeded\n");
failed = 1;
goto fin;

View File

@ -516,7 +516,7 @@ int main(int argc, char *argv[])
return EXIT_FAILURE;
}
/* Stores at max 10 image file names*/
if(num_images> SIZE_MAX/(OPJ_PATH_LEN * sizeof(char))){
if(num_images> SIZE_MAX/(OPJ_PATH_LEN * sizeof(char)) || num_images < 0){
free(dirptr);
return EXIT_FAILURE;
}else{