Commit Graph

25 Commits (master)

Author SHA1 Message Date
Pierre Joye 75fecefe77 <3 the CI, forgot header for gd_error and unused var, strict mode for the win :) 2021-09-07 22:10:26 +07:00
Pierre Joye e5c84f0b7a Partial fix for #750 2021-09-07 22:03:21 +07:00
Mike Frysinger 82b08997c1 gd_io: replace internal Putchar with gdPutC
Most code is already using gdPutC instead of Putchar -- only the bmp
module is using Putchar.  It's unclear why we have this other form as
they should be equivalent: gdPutC takes an unsigned char (8-bits) and
then calls ctx->putC while Putchar takes a signed int, masks it with
0xff, and then calls ctx->putC.

The history of these funcs goes back to when it's initially imported
as part of the 1.5.0 release, and there doesn't seem to be any notes
as to why.

So change bmp to use gdPutC so we can delete Putchar entirely.  The
function isn't exported so no one should even notice.  Our tests are
still passing, so hopefully that provide good coverage.
2021-01-11 19:15:17 -05:00
Romain DÉOUX d0859134fc Fix #450: Failed to open 1 bit per pixel bitmap
For 1 bit per pixel bitmap images, when the width of the image match
some specific values (for instance, 10px), the image loading fails.
2018-12-31 19:45:21 +01:00
Mike Frysinger ac16bdf2d4 bmp: check return value in gdImageBmpPtr
Closes #447.
2018-07-14 13:54:08 -04:00
Peter Kokot 01c59d840b Remove Git ident attributes
Git ident attributes were in most cases utilized with SVN and keywords
substitutions, where $Id$ were replaced with certain revision from the
repository. In Git this functionality is different. Each $Id$ needs to
be defined in .gitattributes file to be effective. This patch removes
unused and outdated attributes.
2018-06-27 02:04:37 +02:00
Christoph M. Becker 4a43ee1c30 Fix typo
Cf. php/php-src@2d48d734a2.
2018-02-08 18:20:02 +01:00
Mike Frysinger 14ca9e4b23 bmp: check smallest negative value for undefined behavior
oss-fuzz pointed out:
gd_bmp.c:641:18: runtime error: negation of -2147483648 cannot be represented in type 'int';
                                cast to an unsigned type to negate this value to itself

This is a bit of a false positive issue as -2147483648 is -2147483648
with gcc/clang which we check for later on.  But lets check for it up
front to avoid the undefined behavior.
2018-01-26 22:30:10 -05:00
Mike Frysinger 5618b9e82a bmp: be a bit more restrictive in input depths
For OS/2 BMP 1.0 files, the spec says only 1/4/8/24 bit images are
supported, so ignore other depths as invalid.

oss-fuzz pointed out:
gd_bmp.c:670:22: runtime error: shift exponent 12803 is too large for 32-bit type 'int'
2018-01-26 21:53:05 -05:00
Christoph M. Becker 880c9f6def 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.
2017-08-24 14:32:20 +02:00
Christoph M. Becker 9a3bd7077e Group the supported image formats in the menu of the docs
To do so we have to add Menu.txt to the project, but we can ignore
Languages.txt and Topics.txt, at least for now.
2016-08-14 16:11:05 +02:00
Christoph M. Becker 92991d1630 Fix issue #276: Sometimes pixels are missing when storing images as BMPs
That happens only when RLE is applied. The culprit is in compress_row(),
where the rightmost pixels which wouldn't be run-length encoded were
ignored; instead we now add them uncompressed to the `row`.
2016-07-24 23:45:28 +02:00
Christoph M. Becker cc6d20b36f Revert "Fix issue #276: Sometimes pixels are missing when storing images as BMPs"
This reverts commit b355a7f392, because
the test case is broken and has to be fixed.
2016-07-24 23:19:19 +02:00
Christoph M. Becker b355a7f392 Fix issue #276: Sometimes pixels are missing when storing images as BMPs
That happens only when RLE is applied. The culprit is in compress_row(),
where the rightmost pixels which wouldn't be run-length encoded were
ignored; instead we now add them uncompressed to the `row`.
2016-07-24 23:02:33 +02:00
Christoph M. Becker 497ba7fc3c Fix issue #275: gdImageBmpCtx() may segfault for non-seekable contexts
We must not check for `compression == 1`, but more generally for
`compression`. Furthermore we improve the related documentation.
2016-07-24 15:37:28 +02:00
Christoph M. Becker b0333689ef Document all BGD_DECLARE'd functions
We add only minimal documentation comments for now, but at least that lets
Natural Docs add the function prototypes to the documentation.
2016-07-20 21:24:48 +02:00
Pierre Joye 9afd8c0737 fix coverity CID 95855, missing break 2016-06-20 09:42:16 +07:00
Pierre Joye bb4f6cca59 fix covererity CID 95842, duplicate code 2016-06-20 09:12:31 +07:00
Mike Frysinger 6913dd3cd2 bmp: use double variant of ceil func
We use ceill and ceil in this code, but it's not clear we need the long
double variant of ceill here.  The input multiply is already done with
double precision (the 0.1 literal is a double), and not all C libraries
offer long double variants.  Change to ceil and see if anyone notices.

Closes issue #123.
2016-01-11 00:02:05 -05:00
Ondřej Surý c60d9fe577 Unify the Win32 check to _WIN32 check which is defined by both VC and MinGW 2013-04-23 06:03:59 +02:00
Remi Collet bf14585e5a fix color order in bmp_read_palette, fix bmp_im2im test 2013-04-22 15:23:33 +02:00
pierrejoye e20413bf6b - apply same CS everywhere 2013-04-03 14:23:11 +02:00
tabe 53d6320309 fixed possible segfaults when gdNewDynamicCtx() returns null 2009-06-25 19:05:45 +00:00
tabe e27c3c7f2c fix for FS#204
* gdImageCreateFrom*() returns null if null pointer given
* gdImage*() puts nothing if null pointer given
2009-06-18 13:35:26 +00:00
scottmac 1a022a579b Merge in BMP support, sync up LSB functions. 2008-05-31 19:51:14 +00:00