JPWL: convert: Fix buffer overflow reading an image file less than four characters (#1196)

Fixes #1068
This commit is contained in:
Robert Ancell 2019-11-17 15:09:59 +13:00 committed by Even Rouault
parent cb332992a7
commit 9701b3305d
1 changed files with 1 additions and 1 deletions

View File

@ -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;