Skip to content
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
33c2d33
Added multiplication check to calloc calls in opj_compress, opj_decom…
Eharve14 Jan 13, 2022
d564919
Added multiplication check for calloc calls, see comment on commit 79…
Eharve14 Jan 13, 2022
c261172
Delete settings.json
Eharve14 Jan 13, 2022
fc2d47a
Fixed typo
Eharve14 Jan 13, 2022
85b471f
Merge branch 'master' of https://github.com/Eharve14/openjpeg
Eharve14 Jan 13, 2022
e74ee84
Revised to address int overflow in for loop only
Eharve14 Jan 13, 2022
d8fe126
Revert "Revised to address int overflow in for loop only"
Eharve14 Jan 13, 2022
968cf54
Revised to catch negitive values of num_images
Eharve14 Jan 13, 2022
efa9c7e
Revised to casts, deleted all other changes
Eharve14 Jan 13, 2022
98f4ace
style updates
Eharve14 Jan 13, 2022
a0b7102
Style part two
Eharve14 Jan 13, 2022
3058194
I am bad and I feel bad, I should have just used the scrypt
Eharve14 Jan 13, 2022
7c42257
Why, why is this happening
Eharve14 Jan 13, 2022
323a089
Update src/bin/jp2/opj_dump.c
rouault Jan 13, 2022
e27cfb3
Update src/bin/jp2/opj_dump.c
rouault Jan 13, 2022
ab6c7c7
Added overflow check to get_num_images, defined num_images as unsigne…
Eharve14 Jan 13, 2022
dbe64d6
Fixed style
Eharve14 Jan 13, 2022
957a6cd
Revert "Fixed style"
Eharve14 Jan 13, 2022
cbc8b26
Revert "Added overflow check to get_num_images, defined num_images as…
Eharve14 Jan 13, 2022
3882583
Merge pull request #1 from uclouvain/master
Eharve14 Jan 13, 2022
912a144
Fixed issues with get_num_images, moved the zero file check to preven…
Eharve14 Jan 13, 2022
96c6587
Same as last
Eharve14 Jan 13, 2022
21ac2bb
Merge branch 'master' of https://github.com/Eharve14/openjpeg
Eharve14 Jan 13, 2022
081bc3e
Fixed style
Eharve14 Jan 13, 2022
e011787
Added import of limits.h, revised overflow check, Redefined Return va…
Eharve14 Jan 14, 2022
7766d9c
Added return statement to break iteration
Eharve14 Jan 15, 2022
67536c7
Style fix
Eharve14 Jan 15, 2022
43bf2be
Re-Revised to use break statement instead of return.
Eharve14 Jan 15, 2022
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
14 changes: 9 additions & 5 deletions src/bin/jp2/opj_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,9 @@ static unsigned int get_num_images(char *imgdirpath)
continue;
}
num_images++;
if (num_images == 0) {
Comment thread
Eharve14 marked this conversation as resolved.
Outdated
fprintf(stderr, "Too many files in folder %s\n", imgdirpath);
Comment thread
rouault marked this conversation as resolved.
}
}
closedir(dir);
return num_images;
Expand Down Expand Up @@ -1957,6 +1960,11 @@ 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 == 0) {
fprintf(stdout, "Folder is empty\n");
ret = 0;
goto fin;
}
dirptr = (dircnt_t*)malloc(sizeof(dircnt_t));
if (dirptr) {
dirptr->filename_buf = (char*)calloc(num_images, OPJ_PATH_LEN * sizeof(
Expand All @@ -1974,11 +1982,7 @@ int main(int argc, char **argv)
ret = 0;
goto fin;
}
if (num_images == 0) {
fprintf(stdout, "Folder is empty\n");
ret = 0;
goto fin;
}

} else {
num_images = 1;
}
Expand Down
16 changes: 10 additions & 6 deletions src/bin/jp2/opj_decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ int get_num_images(char *imgdirpath)
{
DIR *dir;
struct dirent* content;
int num_images = 0;
unsigned int num_images = 0;
Comment thread
Eharve14 marked this conversation as resolved.

/*Reading the input images from given input directory*/

Expand All @@ -389,6 +389,9 @@ int get_num_images(char *imgdirpath)
continue;
}
num_images++;
if (num_images == 0) {
fprintf(stderr, "Too many files in folder %s\n", imgdirpath);
Comment thread
Eharve14 marked this conversation as resolved.
}
}
closedir(dir);
return num_images;
Expand Down Expand Up @@ -1367,6 +1370,11 @@ 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 == 0) {
fprintf(stderr, "Folder is empty\n");
failed = 1;
goto fin;
}
dirptr = (dircnt_t*)calloc(1, sizeof(dircnt_t));
if (!dirptr) {
destroy_parameters(&parameters);
Expand Down Expand Up @@ -1394,11 +1402,7 @@ int main(int argc, char **argv)
failed = 1;
goto fin;
}
if (num_images == 0) {
fprintf(stderr, "Folder is empty\n");
failed = 1;
goto fin;
}

} else {
num_images = 1;
}
Expand Down
15 changes: 9 additions & 6 deletions src/bin/jp2/opj_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static int get_num_images(char *imgdirpath)
{
DIR *dir;
struct dirent* content;
int num_images = 0;
unsigned int num_images = 0;
Comment thread
Eharve14 marked this conversation as resolved.

/*Reading the input images from given input directory*/

Expand All @@ -141,6 +141,9 @@ static int get_num_images(char *imgdirpath)
continue;
}
num_images++;
if (num_images == 0) {
fprintf(stderr, "Too many files in folder %s\n", imgdirpath);
Comment thread
Eharve14 marked this conversation as resolved.
}
}
closedir(dir);
return num_images;
Expand Down Expand Up @@ -510,7 +513,10 @@ 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 == 0) {
fprintf(stdout, "Folder is empty\n");
goto fails;
}
dirptr = (dircnt_t*)malloc(sizeof(dircnt_t));
if (!dirptr) {
return EXIT_FAILURE;
Expand All @@ -536,10 +542,7 @@ int main(int argc, char *argv[])
if (load_images(dirptr, img_fol.imgdirpath) == 1) {
goto fails;
}
if (num_images == 0) {
fprintf(stdout, "Folder is empty\n");
goto fails;
}

} else {
num_images = 1;
}
Expand Down