Skip to content

Commit

Permalink
Fix buffer overflow reading an image file less than four characters
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-ancell committed May 26, 2019
1 parent f4d6578 commit 76f9f0d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/bin/jpwl/convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,7 @@ int imagetopgx(opj_image_t * image, const char *outfile)
const size_t olen = strlen(outfile);
const size_t dotpos = olen - 4;
const size_t total = dotpos + 1 + 1 + 4; /* '-' + '[1-3]' + '.pgx' */
if (outfile[dotpos] != '.') {
if (olen < 4 || outfile[dotpos] != '.') {
/* `pgx` was recognized but there is no dot at expected position */
fprintf(stderr, "ERROR -> Impossible happen.");
return 1;
Expand Down

0 comments on commit 76f9f0d

Please sign in to comment.