opj_mj2_extract: Avoid segfault for long filenames

This commit is contained in:
szukw000 2018-03-13 18:11:54 +01:00 committed by Even Rouault
parent 2c7eb4fed9
commit 1eb9a57ac1
No known key found for this signature in database
GPG Key ID: 33EBBFC47B3DD87D
1 changed files with 6 additions and 1 deletions

View File

@ -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) {