diff options
| author | Even Rouault <even.rouault@mines-paris.org> | 2018-11-16 09:42:19 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-11-16 09:42:19 +0100 |
| commit | 92023cd6c377e0384a7725949b25655d4d94dced (patch) | |
| tree | e131e959b4800290969b1e3b3f644ed9f264a803 /src | |
| parent | c196b23b90321b5c7e3238294607a2e8626c503f (diff) | |
| parent | cab352e249ed3372dd9355c85e837613fff98fa2 (diff) | |
Merge pull request #1160 from hlef/master
jp3d/jpwl convert: fix write stack buffer overflow
Diffstat (limited to 'src')
| -rw-r--r-- | src/bin/jp2/convert.c | 5 | ||||
| -rw-r--r-- | src/bin/jp3d/convert.c | 4 | ||||
| -rw-r--r-- | src/bin/jpwl/convert.c | 2 |
3 files changed, 8 insertions, 3 deletions
diff --git a/src/bin/jp2/convert.c b/src/bin/jp2/convert.c index fa02e31c..e670cd82 100644 --- a/src/bin/jp2/convert.c +++ b/src/bin/jp2/convert.c @@ -2233,6 +2233,11 @@ int imagetopnm(opj_image_t * image, const char *outfile, int force_split) opj_version(), wr, hr, max); red = image->comps[compno].data; + if (!red) { + fclose(fdest); + continue; + } + adjustR = (image->comps[compno].sgnd ? 1 << (image->comps[compno].prec - 1) : 0); diff --git a/src/bin/jp3d/convert.c b/src/bin/jp3d/convert.c index 23fd70b0..acad8f82 100644 --- a/src/bin/jp3d/convert.c +++ b/src/bin/jp3d/convert.c @@ -297,8 +297,8 @@ opj_volume_t* pgxtovolume(char *relpath, opj_cparameters_t *parameters) fprintf(stdout, "[INFO] Loading %s \n", pgxfiles[pos]); fseek(f, 0, SEEK_SET); - fscanf(f, "PG%[ \t]%c%c%[ \t+-]%d%[ \t]%d%[ \t]%d", temp, &endian1, &endian2, - signtmp, &prec, temp, &w, temp, &h); + fscanf(f, "PG%31[ \t]%c%c%31[ \t+-]%d%31[ \t]%d%31[ \t]%d", temp, &endian1, + &endian2, signtmp, &prec, temp, &w, temp, &h); i = 0; sign = '+'; diff --git a/src/bin/jpwl/convert.c b/src/bin/jpwl/convert.c index f3bb670b..73c1be72 100644 --- a/src/bin/jpwl/convert.c +++ b/src/bin/jpwl/convert.c @@ -1349,7 +1349,7 @@ opj_image_t* pgxtoimage(const char *filename, opj_cparameters_t *parameters) } fseek(f, 0, SEEK_SET); - if (fscanf(f, "PG%[ \t]%c%c%[ \t+-]%d%[ \t]%d%[ \t]%d", temp, &endian1, + if (fscanf(f, "PG%31[ \t]%c%c%31[ \t+-]%d%31[ \t]%d%31[ \t]%d", temp, &endian1, &endian2, signtmp, &prec, temp, &w, temp, &h) != 9) { fprintf(stderr, "ERROR: Failed to read the right number of element from the fscanf() function!\n"); |
