Skip to content

Commit

Permalink
jp3d/jpwl convert: fix write stack buffer overflow
Browse files Browse the repository at this point in the history
Missing buffer length formatter in fscanf call might lead to write
stack buffer overflow.

fixes #1044 (CVE-2017-17480)
  • Loading branch information
hlef committed Oct 22, 2018
1 parent 0e6a555 commit 720cf87
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/bin/jp3d/convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ 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,
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;
Expand Down
2 changes: 1 addition & 1 deletion src/bin/jpwl/convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 720cf87

Please sign in to comment.