diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2017-08-24 14:32:20 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2017-08-24 14:32:20 +0200 |
commit | 880c9f6def862043bed078a190d7a9e96d01aa37 (patch) | |
tree | 14d7664691d870053f17a31604189384479e8ea2 /src/gd_bmp.c | |
parent | 3083d2db2a70b55c8aa49459ea7e1431e1586b72 (diff) | |
download | libgd-880c9f6def862043bed078a190d7a9e96d01aa37.tar.gz |
Back-port fix for PHP bug 75111
Although libgd is not really affected by this issue, because contrary
to PHP's bundled libgd it does not allow to read from negative offsets,
we consider it still a bug that `dynamicSeek()` does not behave like
`fileSeek()` with regard to negative positions.
As this behavior cannot be probed from outside, we omit the regression
test.
Diffstat (limited to 'src/gd_bmp.c')
-rw-r--r-- | src/gd_bmp.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/gd_bmp.c b/src/gd_bmp.c index 1eb2ebe..7b29c1a 100644 --- a/src/gd_bmp.c +++ b/src/gd_bmp.c @@ -761,7 +761,9 @@ static int bmp_read_direct(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, b /* There is a chance the data isn't until later, would be wierd but it is possible */ if (gdTell(infile) != header->off) { /* Should make sure we don't seek past the file size */ - gdSeek(infile, header->off); + if (!gdSeek(infile, header->off)) { + return 1; + } } /* The line must be divisible by 4, else its padded with NULLs */ @@ -856,7 +858,9 @@ static int bmp_read_1bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp /* There is a chance the data isn't until later, would be wierd but it is possible */ if (gdTell(infile) != header->off) { /* Should make sure we don't seek past the file size */ - gdSeek(infile, header->off); + if (!gdSeek(infile, header->off)) { + return 1; + } } /* The line must be divisible by 4, else its padded with NULLs */ @@ -924,7 +928,9 @@ static int bmp_read_4bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp /* There is a chance the data isn't until later, would be wierd but it is possible */ if (gdTell(infile) != header->off) { /* Should make sure we don't seek past the file size */ - gdSeek(infile, header->off); + if (!gdSeek(infile, header->off)) { + return 1; + } } /* The line must be divisible by 4, else its padded with NULLs */ @@ -1009,7 +1015,9 @@ static int bmp_read_8bit(gdImagePtr im, gdIOCtxPtr infile, bmp_info_t *info, bmp /* There is a chance the data isn't until later, would be wierd but it is possible */ if (gdTell(infile) != header->off) { /* Should make sure we don't seek past the file size */ - gdSeek(infile, header->off); + if (!gdSeek(infile, header->off)) { + return 1; + } } /* The line must be divisible by 4, else its padded with NULLs */ |