Avoid segfault for long filenames
This commit is contained in:
parent
2c7eb4fed9
commit
d409ce8fb1
|
@ -82,7 +82,7 @@ int main(int argc, char *argv[])
|
||||||
mj2_sample_t *sample;
|
mj2_sample_t *sample;
|
||||||
unsigned char* frame_codestream;
|
unsigned char* frame_codestream;
|
||||||
FILE *file, *outfile;
|
FILE *file, *outfile;
|
||||||
char outfilename[50];
|
char outfilename[FILENAME_MAX];
|
||||||
mj2_dparameters_t parameters;
|
mj2_dparameters_t parameters;
|
||||||
|
|
||||||
if (argc != 3) {
|
if (argc != 3) {
|
||||||
|
@ -91,6 +91,11 @@ int main(int argc, char *argv[])
|
||||||
return 1;
|
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");
|
file = fopen(argv[1], "rb");
|
||||||
|
|
||||||
if (!file) {
|
if (!file) {
|
||||||
|
|
Loading…
Reference in New Issue