opj_mj2_extract: Avoid segfault for long filenames
This commit is contained in:
parent
2c7eb4fed9
commit
1eb9a57ac1
|
@ -82,7 +82,7 @@ int main(int argc, char *argv[])
|
|||
mj2_sample_t *sample;
|
||||
unsigned char* frame_codestream;
|
||||
FILE *file, *outfile;
|
||||
char outfilename[50];
|
||||
char outfilename[FILENAME_MAX];
|
||||
mj2_dparameters_t parameters;
|
||||
|
||||
if (argc != 3) {
|
||||
|
@ -91,6 +91,11 @@ int main(int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (strlen(argv[2]) + 11 > sizeof(outfilename)) {
|
||||
fprintf(stderr, "filename %d too long\n", strlen(argv[2]) + 11);
|
||||
return 1;
|
||||
}
|
||||
|
||||
file = fopen(argv[1], "rb");
|
||||
|
||||
if (!file) {
|
||||
|
|
Loading…
Reference in New Issue