Commit Graph

1891 Commits (59574eab0fbf8189ddf29aafec768346481330a9)

Author SHA1 Message Date
Peter Kokot 59574eab0f Upgrade AX_REQUIRE_DEFINED macro file
This patch bumps current file version from the Autoconf Archive from
1 to 2:
http://git.savannah.gnu.org/cgit/autoconf-archive.git/tree/m4/ax_require_defined.m4

Changes:

https links in the file comments
2018-09-06 00:32:54 -04:00
Peter Kokot 70c972a7c2 Upgrade AX_PTHREAD macro file
This patch bumps current file version from the Autoconf Archive from
23 to 24:
http://git.savannah.gnu.org/cgit/autoconf-archive.git/tree/m4/ax_pthread.m4

Changes:
- https links in the file comments
2018-09-06 00:32:39 -04:00
Peter Kokot 5d87c7e3ee Upgrade AX_CFLAGS_WARN_ALL macro file
This patch bumps current file version from the Autoconf Archive from
15 to 16:
http://git.savannah.gnu.org/cgit/autoconf-archive.git/tree/m4/ax_cflags_warn_all.m4

Changes:
- https links in the file comments
2018-09-06 00:31:58 -04:00
Peter Kokot 857738a5ac Upgrade AX_APPEND_FLAG macro file
This patch bumps current serial file version from the Autoconf Archive
from 6 to 8.

Changes:
- simplified and more permissive license
- https links in the file comments
2018-09-06 00:31:25 -04:00
Peter Kokot d81a1383d7 Remove HAVE_LIMITS_H
The `<limits.h>` header file is part of the standard C89 headers [1] and
on current systems there is no need to manually check if header is
present anymore.

Since the libgd requires at least C89 or greater, the `HAVE_LIMITS_H`
symbol defined by Autoconf in configure.ac [2], and Cmake build system
files can be removed and simplifed.

Refs:
[1] https://port70.net/~nsz/c/c89/c89-draft.html#4.1.2
[2] https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/headers.m4
2018-09-06 00:30:15 -04:00
Peter Kokot 1e7f93922f Remove HAVE_ERRNO_H
The `<errno.h>` header file is part of the standard C89 headers [1] and
on older systems there needed to be also a manual check if header is
present.

Since libgd requires at least C89 or greater, the `HAVE_ERRNO_H`
symbol defined by Autoconf in configure.ac [2], and Cmake build system
files can be removed and simplifed.

Refs:
[1] https://port70.net/~nsz/c/c89/c89-draft.html#4.1.3
[2] https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/headers.m4
2018-09-05 01:39:49 -04:00
Mike Frysinger 96d68e3614 docs: use UTF-8 encoding for README.JPN
This file is encoded as ISO-2022-JP.  Convert to the more common and
modern UTF-8.
2018-09-04 21:29:46 -04:00
Mike Frysinger a6dd3491a0 drop redundant color checks #456
These funcs were updated to always reject negative color values at
their start.  There's no need to keep these embedded negative checks.
2018-08-31 01:22:32 -04:00
Mike Frysinger 4fc6d8a0d6 rework ifdef header protection #456
Move all content inside of the header ifdef checks.  There's
no need to have the C++ checks and includes outside of them.
2018-08-31 01:21:34 -04:00
Mike Frysinger c9c4f0ed53 configure: support libjpeg.pc #455
Since newer jpeg/jpeg-turbo releases include a pc file,
optionally support it.

Closes #455.
2018-08-26 12:14:33 -04:00
Mike Frysinger e6bb110663 drop netware support #294
We have no way of testing netware, and the OS has been dead for years.
PHP also has dropped support for it.

Closes #294.
2018-08-25 12:50:23 -04:00
Mike Frysinger ac16bdf2d4 bmp: check return value in gdImageBmpPtr
Closes #447.
2018-07-14 13:54:08 -04:00
Mike Frysinger 8779ca15b4 travis: add some source/lint tests
We probably should look into cpplint, but until then, these are
some simple hacks to catch common mistakes.
2018-07-14 13:35:45 -04:00
Christoph M. Becker 08ae745426 Merge branch 'pull-request/444'
* pull-request/444:
  Remove Git ident attributes
2018-06-27 12:13:42 +02: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
Mike Frysinger 1e3a3d9819 examples: fix build errors in previous cleanup here
There was a double paste error in the name "nnquant", and the link
line needs to come after we add programs.  This was missed locally
due to the conditional logic (blah).
2018-06-26 04:07:10 -04:00
Mike Frysinger 748578ff3f gdft: change strncpy usage to memcpy
All the uses of strncpy in here are based on strlen of the input, so
there's no need to run through an str-based func again.  Switch to a
straight memcpy.  Plus this avoids static checkers that blindly choke
on strncpy.  The code was already adding a trailing NUL byte, so that
isn't problematic either.
2018-06-22 00:09:50 -04:00
Mike Frysinger e9bf9ddf1d annotate: rewrite code to avoid fixed buffers
Avoid fgets which can chop lines, and strncpy which in this case was
missing a NUL terminating byte.
2018-06-22 00:04:07 -04:00
Mike Frysinger 08b0dbaec6 move (redundant) ifdef checks from source to build files
We've been tracking program deps in the build files, so it ends up
being redundant for a lot of our test/example programs.  Clean them
up, and update some of the cmake/automake files as needed.
2018-06-21 23:55:11 -04:00
Mike Frysinger fd06f7f83c clean up trailing whitespace/newlines
This is preparation for adding some linting checks for new commits from
people.  Shouldn't be any functional changes here (tests still pass!).
2018-06-21 22:47:42 -04:00
Mike Frysinger aac77143dd convert all files to native line encodings
A bunch of these files were committed with Windows line encodings.
Strip all those ^M gremlins out as people working on Windows can
use git's autocrlf setting to convert back and forth as needed.
2018-06-21 21:44:54 -04:00
Mike Frysinger c4ee95d1a4 tests: clean up various buffers/objects
These tests aren't broken because they didn't free the buffers, but
by cleaning these up, it's safe to run the testsuite through the leak
sanitizer (LSAN) to detect real leaks in the rest of the library.

See the previous commit 98b3f04b21 as
an example of LSAN being useful.
2018-06-21 21:22:31 -04:00
Mike Frysinger 98b3f04b21 png: fix memory leak with error handlers in outputs
If the png error handle is triggered during output, the allocated
rows aren't freed.  Change the allocation to calloc to zero out all
the rows, and then walk them in the jump callback to release them.
2018-06-21 21:18:08 -04:00
Mike Frysinger c6f413f52c scrub OLDER_GD define
This has never been used, so punt it.
2018-06-21 20:41:31 -04:00
Haegul Pyun 6653f3b535 Fix #440: new_width & new_height exception handling
Since the cos range is a real number range, there is a possibility of negative numbers.
- handling fabs new_width & new_height
2018-04-18 15:03:48 +02:00
Christoph M. Becker d9157ebb08 Enable GD and GD2 formats for native Windows toolchain
Actually, this should be configurable, but we're sticking with the
hard-coded defaults for now.
2018-04-05 16:47:18 +02:00
Christoph M. Becker 7f1b92b461 Merge branch 'pull-request/437'
* pull-request/437:
  Updated myself in CONTRIBUTORS
2018-04-05 12:29:33 +02:00
Mateusz Loskot 39eb7d5dd8
Updated myself in CONTRIBUTORS 2018-04-05 12:08:15 +02:00
Christoph M. Becker 4a43ee1c30 Fix typo
Cf. php/php-src@2d48d734a2.
2018-02-08 18:20:02 +01:00
Christoph M. Becker 845f1d38c5 Fix dist build (*cough*) 2018-02-03 19:13:15 +01:00
Christoph M. Becker 86399328e9 Fix dist build 2018-02-03 18:57:15 +01:00
Christoph M. Becker 2dbd8f6e66 Fix #383 (amendment)
When reading images in GD or GD2 format, we have to ensure that the
transparent color is not set, if it would refer to a non-extant palette
entry.

We back that up with respective regression tests.
2018-02-03 18:31:16 +01:00
Christoph M. Becker a15130c6bb Fix #432: gdImageCrop neglecting transparency
When using `gdImageCopy()` for image cropping, we have to make sure
that it doesn't use alpha blending (the current default), but rather
`gdEffectReplace`.  We reset the `alphaBlendingFlag` after finishing
the copy operation.
2018-02-02 16:36:00 +01:00
Mike Frysinger 0be86e1926 gd/gd2: make sure transparent palette index is within bounds #383
The gd image formats allow for a palette of 256 colors,
so if the transparent index is out of range, disable it.
2018-01-31 14:50:16 -05:00
Mike Frysinger 14b8020dda make gd/gd2 image formats optional #428
We still enable them by default, but we'll probably flip them off
in the next major release series.
2018-01-30 17:58:44 -05:00
Mike Frysinger 1daf261a83 include getopt for Windows builds
Since getopt is only needed by various helper programs, we start a new
program utility static library to stuff things into so they don't fill
up the gd library itself.

This comes from NetBSD.  Fixes #401.
2018-01-29 18:09:57 -05:00
Christoph M. Becker a11f47475e Fix #420: Potential infinite loop in gdImageCreateFromGifCtx
Due to a signedness confusion in `GetCode_` a corrupt GIF file can
trigger an infinite loop.  Furthermore we make sure that a GIF without
any palette entries is treated as invalid *after* open palette entries
have been removed.

CVE-2018-5711

See also https://bugs.php.net/bug.php?id=75571.
2018-01-29 15:17:12 +01:00
Christoph M. Becker 7ff626c48a Fix integer-overflow in gdImageCreateFromGd2Ctx
oss-fuzz pointed out:
gd_gd2.c:456:10: runtime error: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'

We must not allow chunk sizes (aka. lengths) of INT_MAX, since we need
to alloc size+1 bytes.
2018-01-29 13:30:01 +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
Mike Frysinger f0a059be6c gd2: use existing overflow2 helper rather than an ad-hoc version 2018-01-26 02:23:29 -05:00
Mike Frysinger 0089d11784 gd2: fix some signed overflows
oss-fuzz pointed out:
gd_gd2.c:441:11: runtime error: signed integer overflow: 65535 * 65535 cannot be represented in type 'int'

Add some checks on the inputs from the header file and which are used
later on in multiplication.
2018-01-26 02:20:26 -05:00
Mike Frysinger b402909c42 tga: delay calculation to avoid undefined behavior
oss-fuzz pointed out:
gd_tga.c:209:52: runtime error: signed integer overflow: 838848000 * 3 cannot be represented in type 'int'

This is somewhat of a false positive as we already have overflow checks
after this assignment, but we can delay the code until afterwards to
avoid warnings.
2018-01-26 02:13:26 -05:00
Mike Frysinger 9fa3abd2e6 gif: fix out-of-bounds read w/corrupted lzw data
oss-fuzz pointed out:
gd_gif_in.c:605:16: runtime error: index 5595 out of bounds for type 'int [4096]'

Add some bounds checking on each code that we read from the file.
2018-01-26 01:57:52 -05:00
Mike Frysinger a8f1d5cab0 wbmp: getmbi: use unsigned int to avoid undefined shift behavior
oss-fuzz pointed out:
wbmp.c:48:14: runtime error: left shift of 253751679 by 7 places cannot be represented in type 'int'

See previous commit for more details.
2018-01-25 23:25:56 -05:00
Mike Frysinger 772d0107a6 gdGetIntLSB: use unsigned int to avoid undefined shift behavior
oss-fuzz pointed out:
gd_io.c:174:10: runtime error: left shift of 255 by 24 places cannot be represented in type 'int'

See previous commit for more details.
2018-01-25 23:18:56 -05:00
Mike Frysinger 24d352576c gdGetInt: use unsigned int to avoid undefined shift behavior
oss-fuzz pointed out:
gd_io.c:139:14: runtime error: left shift of 199 by 24 places cannot be represented in type 'int'

Switch the temp var we use here to unsigned to avoid that.  We do an
unsigned int to a signed int at the end which is undefined, but since
compilers don't seem to mind that, we won't care just yet.  It also
makes the code match gdGetIntLSB behavior.
2018-01-25 23:02:32 -05:00
Mike Frysinger fdbd8df682 add underscores around attributes
We use __attribute__ instead of attribute everywhere to avoid namespace
issues, so make sure we use the same style for the attribute options too.
2018-01-25 21:51:03 -05:00
Tim D. Smith f3dc031df7 Make ReadOK fail on short reads 2018-01-24 21:05:41 -05:00
Tim D. Smith 03d23738bc Remove apple-gcc42 from bootstrap advice
The package doesn't exist anymore (and Xcode clang is good now).
2018-01-24 19:58:51 -05:00