Added multiplication check for calloc calls, see comment on commit 79c7d7a
This commit is contained in:
parent
33c2d33c5d
commit
d564919d3a
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"files.associations": {
|
||||||
|
"cstdlib": "c"
|
||||||
|
}
|
||||||
|
}
|
|
@ -1367,7 +1367,11 @@ int main(int argc, char **argv)
|
||||||
if (img_fol.set_imgdir == 1) {
|
if (img_fol.set_imgdir == 1) {
|
||||||
int it_image;
|
int it_image;
|
||||||
num_images = get_num_images(img_fol.imgdirpath);
|
num_images = get_num_images(img_fol.imgdirpath);
|
||||||
|
if( num_images > SIZE_MAX/(sizeof(char)* OPJ_PATH_LEN)){
|
||||||
|
fprintf(stderr, "Max number of images exceeded\n");
|
||||||
|
failed = 1;
|
||||||
|
goto fin;
|
||||||
|
} else {
|
||||||
dirptr = (dircnt_t*)calloc(1, sizeof(dircnt_t));
|
dirptr = (dircnt_t*)calloc(1, sizeof(dircnt_t));
|
||||||
if (!dirptr) {
|
if (!dirptr) {
|
||||||
destroy_parameters(¶meters);
|
destroy_parameters(¶meters);
|
||||||
|
@ -1394,6 +1398,7 @@ int main(int argc, char **argv)
|
||||||
failed = 1;
|
failed = 1;
|
||||||
goto fin;
|
goto fin;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (num_images == 0) {
|
if (num_images == 0) {
|
||||||
fprintf(stderr, "Folder is empty\n");
|
fprintf(stderr, "Folder is empty\n");
|
||||||
failed = 1;
|
failed = 1;
|
||||||
|
|
|
@ -516,6 +516,10 @@ int main(int argc, char *argv[])
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
/* Stores at max 10 image file names*/
|
/* Stores at max 10 image file names*/
|
||||||
|
if(num_images> SIZE_MAX/(OPJ_PATH_LEN * sizeof(char))){
|
||||||
|
free(dirptr);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}else{
|
||||||
dirptr->filename_buf = (char*) calloc((size_t) num_images,
|
dirptr->filename_buf = (char*) calloc((size_t) num_images,
|
||||||
OPJ_PATH_LEN * sizeof(char));
|
OPJ_PATH_LEN * sizeof(char));
|
||||||
if (!dirptr->filename_buf) {
|
if (!dirptr->filename_buf) {
|
||||||
|
@ -535,7 +539,7 @@ int main(int argc, char *argv[])
|
||||||
if (load_images(dirptr, img_fol.imgdirpath) == 1) {
|
if (load_images(dirptr, img_fol.imgdirpath) == 1) {
|
||||||
goto fails;
|
goto fails;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (num_images == 0) {
|
if (num_images == 0) {
|
||||||
fprintf(stdout, "Folder is empty\n");
|
fprintf(stdout, "Folder is empty\n");
|
||||||
goto fails;
|
goto fails;
|
||||||
|
|
Loading…
Reference in New Issue