Merge branch 'pr1095'

This commit is contained in:
Even Rouault 2018-09-22 23:12:50 +02:00
commit aaf48ee6ba
No known key found for this signature in database
GPG Key ID: 33EBBFC47B3DD87D
1 changed files with 12 additions and 1 deletions

View File

@ -145,10 +145,21 @@ int main(int argc, char *argv[])
fread(frame_codestream, sample->sample_size - 8, 1, fread(frame_codestream, sample->sample_size - 8, 1,
file); /* Assuming that jp and ftyp markers size do*/ file); /* Assuming that jp and ftyp markers size do*/
sprintf(outfilename, "%s_%05d.j2k", argv[2], snum); {
int num = snprintf(outfilename, sizeof(outfilename),
"%s_%05d.j2k", argv[2],
snum);
if (num >= sizeof(outfilename)) {
fprintf(stderr, "maximum length of output prefix exceeded\n");
free(frame_codestream);
return 1;
}
}
outfile = fopen(outfilename, "wb"); outfile = fopen(outfilename, "wb");
if (!outfile) { if (!outfile) {
fprintf(stderr, "failed to open %s for writing\n", outfilename); fprintf(stderr, "failed to open %s for writing\n", outfilename);
free(frame_codestream);
return 1; return 1;
} }
fwrite(frame_codestream, sample->sample_size - 8, 1, outfile); fwrite(frame_codestream, sample->sample_size - 8, 1, outfile);