Commit Graph

1237 Commits (master)

Author SHA1 Message Date
wilson chen b73137fcd4 Remove config.h in gdpp
Remove config.h & jpeg defines in gdpp.h & gdpp.cxx.
2019-11-18 23:09:44 -05:00
willson-chen ac7118680d Fix #539: Add RAQM support for cmake
* Add `ENABLE_RAQM` option to CMakeLists.txt
* Add cmake module FindRAQM.cmake
2019-11-02 00:59:43 -06:00
willson-chen b2011428f5 fixed cmake failed with MinGW
If BUILD_STATIC_LIBS is not On, cmake will failed for target ${GD_LIB_STATIC} doesn't exist.
2019-09-29 12:56:39 -04:00
Jonas Meurer e13a342c07 Fix #501: Uninitialized read in gdImageCreateFromXbm (CVE-2019-11038)
Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2019-11038
Bug-Debian: https://bugs.debian.org/929821
Bug: https://github.com/libgd/libgd/issues/501

We have to ensure that `sscanf()` does indeed read a hex value here,
and bail out otherwise.

Original patch by Christoph M. Becker <cmbecker69@gmx.de> for PHP libgd ext.
https://git.php.net/?p=php-src.git;a=commit;h=ed6dee9a198c904ad5e03113e58a2d2c200f5184
2019-09-02 04:25:39 -04:00
Lance Wang bbb46ab9a5 annotate: be consistent in error messages 2019-08-03 12:54:08 -04:00
Christoph M. Becker 55f3b360c0 Fix #499: gdImageGifAnimAddPtr: heap corruption with 2 identical images
Whenever `gdImageGifAnimAddPtr()` calls `gdImageGifAnimAddCtx()` and
the latter fails, we must not call `gdDPExtractData()`; otherwise a
double-free would occur.  Since `gdImageGifAnimAddCtx` is a void
function, and we can't change that for BC reasons, we're introducing
a static helper which is used internally.
2019-05-26 11:01:14 +02:00
Iman Hosseini 3ad4e65075 Fixed typo in the comments.
Fixed typo "As will all ..." -> "As with all ..."
2019-05-06 10:36:53 +02:00
Mike Frysinger a91cb62f01 add stub ABI funcs when formats are disabled #345
We do this for some funcs already, so add jpeg/png/tiff/liq/webp
stubs too.  This keeps our ABI stable and lets code do runtime
detection instead.
2019-02-09 13:16:57 -05:00
Christoph M. Becker 553702980a Fix #492: Potential double-free in gdImage*Ptr()
Whenever `gdImage*Ptr()` calls `gdImage*Ctx()` and the latter fails, we
must not call `gdDPExtractData()`; otherwise a double-free would
happen.  Since `gdImage*Ctx()` are void functions, and we can't change
that for BC reasons, we're introducing static helpers which are used
internally.

We're adding a regression test for `gdImageJpegPtr()`, but not for
`gdImageGifPtr()` and `gdImageWbmpPtr()` since we don't know how to
trigger failure of the respective `gdImage*Ctx()` calls.

This potential security issue has been reported by Solmaz Salimi (aka.
Rooney).
2019-01-17 11:54:55 +01:00
Christoph M. Becker 21406b1a43 Fix #351: gdImageFilledArc() doesn't properly draw pies
The fix for PHP bug 43828[1] changed the algorithm from drawing filled
pies from drawing multiple triangles to drawing a single polygon.  Due
to quirks of the filled polygon drawing algorithm, we had to filter out
extraneous vertices.  This lead, however, to a bug regarding displaced
starting and ending points near 90° and 270° degrees, which we fix by
reinserting these vertices if they had been removed.

[1] <https://bugs.php.net/bug.php?id=43828>
2019-01-16 19:39:42 +01:00
Christoph M. Becker 0414bb2da0 Fix misleading variable type
`m` and `n` are supposed to be plain integers, so we shouldn't declare
them as `gdFixed`.
2019-01-10 23:26:09 +01: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 e13956b6db
Merge pull request #484 from omron93/gdcache
Don't dereference a null pointer when cache size is 1
2018-11-26 13:28:28 -05:00
Christoph M. Becker 6613094e5d Fix #486: gdImageCropAuto(…, GD_CROP_SIDES) crops left but not right
`gdGuessBackgroundColorFromCorners()` is supposed to handle *all* cases
where an image has exactly two equal colors in the same way.
2018-11-25 17:58:41 +01:00
Christoph M. Becker bda85aaeeb Fix #485: auto cropping has insufficient precision
After calculating the top crop amount, we bail out if the whole image
was going to be cropped away.  The condition to check this
is off-by-one, though, since `y` would be equal to `height` in this
case.  However, `y` would be equal to `height` also in case only the
last row of the image would have to be retained.  We instead check for
`match` which indicates whether all pixels have the same color.

After calculating the bottom crop amount, we must never calculate the
`crop.height` based on the image height, since its irrelevant.

When calculating the left and right crop amount, we must not ignore the
last row of the image.

The partially identical implementation of `gdImageCropThreshold()` has
exactly the same issues, so we fix it as well.

Future scope for *improvements*:

- Replace the `match` flag with respective `goto`s (basically, `break
  2`) is supposed to yield clearer code.
- Don't check the rows which will be top-cropped anyway, when
  calculating the left and right crop amount, for efficiency.
- Join the implementations of calculating the crop rectangle of
  `gdImageCropAuto()` and `gdImageCropThreshold()`.
2018-11-25 14:39:09 +01:00
Christoph M. Becker cf36016918 Fix docs
Cf. <https://github.com/libgd/libgd/issues/298>.
2018-11-24 17:02:01 +01:00
Marek Skalický 774211ee2f
Don't dereference a null pointer when cache size is 1 2018-11-24 14:41:10 +00:00
Ken Brown 529c471f7b Fix #479: Provide a suitable malloc function to liq
liq requires 16 byte alignment, which gdMalloc() doesn't guarantee.
Define and use a new malloc16() function when building with liq.
2018-11-16 00:42:52 -05:00
Peter Kokot 434b639d53 Add leading blank lines check and trim redundant blank newlines 2018-10-05 10:27:50 -04:00
kohldampfer 2dc58f6d0a CMake process of generating VS solution and projects fails, because l… (#471)
CMake process of generating VS solution and projects fails, because libgd_static target is not visible at this point. This is a fix for this problem.

Fixes #467.
2018-09-09 18:26:01 -04:00
Peter Kokot 5dc2dd8b49 Remove HAVE_STDLIB_H
The C89 and later standard defines the `<stdlib.h>` header as part of
the standard headers [1] and on current systems it is always present
and the `HAVE_STDLIB_H` symbol can be removed.

Also Autoconf suggests doing this and relying on C89 or above [2] and [3].

[1] https://port70.net/~nsz/c/c89/c89-draft.html#4.1.2
[2] http://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/headers.m4
[3] https://www.gnu.org/software/autoconf/manual/autoconf-2.69/autoconf.html
2018-09-08 03:29:27 -04:00
Peter Kokot 5fa75ace15 Remove HAVE_STRING_H
The C89 and later standard defines the `<string.h>` header as part of
the standard headers [1] and on current systems it is always present
and the `HAVE_STRING_H` symbol can be removed.

Also Autoconf suggests doing this and relying on C89 or above [2] and [3].

[1] https://port70.net/~nsz/c/c89/c89-draft.html#4.1.2
[2] http://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/headers.m4
[3] https://www.gnu.org/software/autoconf/manual/autoconf-2.69/autoconf.html
2018-09-08 03:16:35 -04:00
Peter Kokot 486467fc8f Remove HAVE_STDDEF_H
The `<stddef.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_STDDEF_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 02:04:22 -04:00
Mike Frysinger 0f98c3fe7a gdkanji: drop another redundant check #456
This statement first checks c>=64 which means c!=0 is always true.
2018-09-06 01:50:11 -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 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 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
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 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 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
Christoph M. Becker 4a43ee1c30 Fix typo
Cf. php/php-src@2d48d734a2.
2018-02-08 18:20:02 +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
Mike Frysinger dd76e8fcf2 generate & install gdlib.pc for cmake builds too #164 2018-01-10 01:56:10 -05:00
Mike Frysinger 60016a4426 include snprintf.c in the dist tarball
The cmake files refer to it for older Windows builds.  Fixes #416.
2018-01-10 00:59:34 -05:00
Christoph M. Becker 712d9ec181 Fix #411: gd_gd.c format documentation appears to be incorrect
The palette headers always consist of 256 palette entries, and if
`\377\377\377\377` is given for the transparency, that means that there
is no transparent color.
2017-09-07 15:27:18 +02:00
Christoph M. Becker c39fa1e03c Document GD 1.x image format 2017-09-03 15:50:42 +02:00
Christoph M. Becker 5176856eae Fix potential memory leak in gdImageStringFTEx()
Of course, we have to free all allocated resources before returning.

Reported by shqking <shqking@gmail.com> to security@libgd.org.
2017-08-29 16:47:24 +02:00
Christoph M. Becker 3b8a69cfe5 Merge branch 'pull-request/346' 2017-08-27 17:45:20 +02:00
Christoph M. Becker 2207e3c88a Fix #381: libgd double-free vulnerability
The issue is that `gdImagePngCtxEx` (which is called by `gdImagePngPtr`
and the other PNG output functions to do the real work) does not return
whether it succeeded or failed, so this is not checked in
`gdImagePngPtr` and the function wrongly assumes everything is okay,
which is not, in this case, because the palette image contains no
palette entries.

We can't change the signature of `gdImagePngCtxEx` for API
compatibility reasons, so we introduce the static helper
`_gdImagePngCtxEx` which returns success respective failure, so
`gdImagePngPtr` and `gdImagePngPtrEx` can check the return value. We
leave it solely to libpng for now to report warnings regarding the
failing write.

CVE-2017-6362
2017-08-27 17:18:34 +02:00
Christoph M. Becker a7a7ece43c Fix #386: gdImageGrayScale() may produce colors
We have to make sure to avoid alpha-blending issues by explicitly
switching to `gdEffectReplace` and to restore the old value afterwards.

We also document the algorithm used by `gdImageGrayScale()` and note
its limitations regarding palette images.
2017-08-27 12:57:03 +02:00
Christoph M. Becker 1c090dc01e Fix #406: webpng -i removes the transparent color
We have to initialize `trans_col` to the value that guards the call to
`gdImageColorTransparent()`. To avoid confusion, we replace the magic
numbers with a macro.
2017-08-25 12:13:19 +02: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 c613bc1698 Close #339: Fix unitialized memory read vulnerability in GIF reading
The stack allocated color map buffers were not zeroed before usage, and
so undefined palette indexes could cause information leakage.

This issue has been reported by Matviy Kotoniy to security@libgd.org in
<CAKm_7a-AO++B6cXYWM_DtycPENG5WNWK7NSEvQ5OmZziMY_JyA@mail.gmail.com>.
2017-08-10 18:31:29 +02:00
Galik 3385b9aebf Truetype font drawing functions now take `const` strings (#400)
The following API functions now accept the font names and the text to be
printed as `const char*` rater than `char*`. This makes the functions
much more `C++` friendly.

gdImageStringFT();
gdImageStringTTF();
gdImageStringFTEx();

Other functions/types affected:

typeed struct fontkey_t;

any2eucjp();
gdTcl_UtfToUniChar();
DetectKanjiCode();
do_convert();
do_check_and_conv();
2017-07-29 11:24:32 -04:00
Mike Frysinger 660abbeb96 fix some unused variable errors when built w/out png 2017-02-15 10:57:24 -05:00
Christoph M. Becker e65415d91c Fix Coverity #155476: potential resource leak
If the reading of GD2 images fails due to a truncated file, we have to
make sure that all resources are freed. We do so by going to `fail`
instead of bailing out early.

This is a minor issue, though, as GD2 isn't recommended for production
use at all.
2017-01-30 12:41:04 +01:00
Christoph M. Becker acc11040cd Fix Coverity #155475: Failure to restore alphaBlendingFlag
Actually, there is no need to change the alphaBlendingFlag in the first
place, if the buffer allocation fails, so we move the allocation
attempt up.
2017-01-30 12:29:02 +01:00
Christoph M. Becker b4d153ba96 Fix and reenable optimized support for reading 1 bps TIFFs
Due to #82 the optimized support for reading 1 bps TIFF files (black &
white) had been disabled. Tony Lew already pointed out a fix in #88.

Furthermore, there was the following missing and improper error handling:
* TIFFReadScanline() returns -1 on error, not 0
* the result of TIFFReadTile() hasn't been checked
* in case of failure of these functions, the error had not been
  propagated

We fix this, and re-enable direct support for 1 bps TIFFs, which is
more memory efficient than the general RGBA support. We also make sure
not to hit any not yet implemented code path.
2017-01-25 23:28:23 +01:00
Christoph M. Becker bffad4da3c Add a test for reading X10 bitmap files
We also improve the related documentation, which didn't mention yet
which X bitmap formats are supported.
2017-01-21 16:56:12 +01:00
Christoph M. Becker 082c544483 Fix #109: XBM reading fails with printed error
When calculating the number of required bytes of an XBM image, we have
to take the line padding into account.
2017-01-20 22:49:28 +01:00
Christoph M. Becker 381e89de16 Fix build issue regarding INT_MAX
For portability gd_gd2.c needs to include <limits.h>.

(cherry picked from commit c9b601a658a79e6ea2aad29fbf60ca6e24ccef1e)
2017-01-19 01:10:40 +01:00
Christoph M. Becker 55ac28a293 Fix #357: 2.2.4: Segfault in test suite.
We make sure to never pass a negative `int` as argument to a `size_t`
parameter.
2017-01-19 01:02:58 +01:00
Christoph M. Becker 1f57639f04 Remove unused functions
gdImageRotate() and gdImageRotate45() are neither used by GD nor
exported, so we remove them.
2017-01-10 18:57:24 +01:00
Christoph M. Becker 69d2fd2c59 Fix #354: Signed Integer Overflow gd_io.c
GD2 stores the number of horizontal and vertical chunks as words (i.e. 2
byte unsigned). These values are multiplied and assigned to an int when
reading the image, what can cause integer overflows. We have to avoid
that, and also make sure that either chunk count is actually greater
than zero. If illegal chunk counts are detected, we bail out from
reading the image.
2016-12-17 17:38:02 +01:00
Christoph M. Becker 1846f48e5f Fix #340: System frozen
gdImageCreate() doesn't check for oversized images and as such is prone
to DoS vulnerabilities. We fix that by applying the same overflow check
that is already in place for gdImageCreateTrueColor().

CVE-2016-9317
2016-12-13 16:02:19 +01:00
Christoph M. Becker 58b6dde319 Fix OOB reads of the TGA decompression buffer
It is possible to craft TGA files which will overflow the decompression
buffer, but not the image's bitmap. Therefore we also have to check for
potential decompression buffer overflows.

This issue had been reported by Ibrahim El-Sayed to security@libgd.org;
a modified case exposing an off-by-one error of the first patch had been
provided by Konrad Beckmann.

This commit is an amendment to commit fb0e0cce, so we use CVE-2016-6906
as well.
2016-12-13 15:51:51 +01:00
Christoph M. Becker fe9ed49daf Fix DOS vulnerability in gdImageCreateFromGd2Ctx()
We must not pretend that there are image data if there are none. Instead
we fail reading the image file gracefully.
2016-12-13 15:33:42 +01:00
Christoph M. Becker 60bfb401ad Fix potential unsigned underflow
No need to decrease `u`, so we don't do it. While we're at it, we also factor
out the overflow check of the loop, what improves performance and readability.

This issue has been reported by Stefan Esser to security@libgd.org.
2016-12-13 15:16:03 +01:00
Christoph M. Becker a49feeae76 Fix double-free in gdImageWebPtr()
The issue is that gdImageWebpCtx() (which is called by gdImageWebpPtr() and
the other WebP output functions to do the real work) does not return whether
it succeeded or failed, so this is not checked in gdImageWebpPtr() and the
function wrongly assumes everything is okay, which is not, in this case,
because there is a size limitation for WebP, namely that the width and
height must by less than 16383.

We can't change the signature of gdImageWebpCtx() for API compatibility
reasons, so we introduce the static helper _gdImageWebpCtx() which returns
success respective failure, so gdImageWebpPtr() and gdImageWebpPtrEx() can
check the return value. We leave it solely to libwebp for now to report
warnings regarding the failing write.

This issue had been reported by Ibrahim El-Sayed to security@libgd.org.

CVE-2016-6912
2016-12-13 14:40:03 +01:00
Christoph M. Becker 4859d69e07 Fix invalid read in gdImageCreateFromTiffPtr()
tiff_invalid_read.tiff is corrupt, and causes an invalid read in
gdImageCreateFromTiffPtr(), but not in gdImageCreateFromTiff(). The culprit
is dynamicGetbuf(), which doesn't check for out-of-bound reads. In this case,
dynamicGetbuf() is called with a negative dp->pos, but also positive buffer
overflows have to be handled, in which case 0 has to be returned (cf. commit
75e29a9).

Fixing dynamicGetbuf() exhibits that the corrupt TIFF would still create
the image, because the return value of TIFFReadRGBAImage() is not checked.
We do that, and let createFromTiffRgba() fail if TIFFReadRGBAImage() fails.

This issue had been reported by Ibrahim El-Sayed to security@libgd.org.

CVE-2016-6911
2016-12-13 13:55:48 +01:00
Christoph M. Becker fb0e0cce0b Fix OOB reads of the TGA decompression buffer
It is possible to craft TGA files which will overflow the decompression
buffer, but not the image's bitmap. Therefore we augment the check for the
bitmap's overflow with a check for the buffer's overflow.

This issue had been reported by Ibrahim El-Sayed to security@libgd.org.

CVE-2016-6906
2016-12-13 13:31:05 +01:00
Christoph M. Becker fea55903ee Fix #338: Fatal and normal libjpeg/ibpng errors not distinguishable
libgd clients need to be able to distinguish between fatal and
"extremely fatal" libjpeg and libpng errors, because in the former case
execution can proceed, but in the latter case libgd calls exit().
Therefore we report fatal errors as GD_WARNING.
2016-11-16 18:10:29 +01:00
Mike Frysinger 5ebbd50cff cmake: add soname info to libgd.so
Pull out the library versioning info out of configure and into a common
script that both cmake & autotools can run.  This way we have a single
source of truth for the versioning info.
2016-11-10 09:09:14 -05:00
Christoph M. Becker 939d49a3a9 Fix #68: gif: buffer underflow reported by AddressSanitizer
The buffer underflow happens at the start of the bitstream and after
each clear code, where the wrap-around is actually unnecessary. To
avoid the buffer underflow we simply initialize scd->last_byte to 2,
instead of adding further control logic to skip the relevant
assignments altogether.

We do not add a regression test, because the buffer underflow could
only be detected with ASAN or a similar memory-checker (or debugging),
and it happens for all proper GIFs anyway, so other tests (such as
tests/gif/gif_im2im) already exhibited the behavior.
2016-10-15 19:00:57 +02:00
Christoph M. Becker 5311087193 Avoid potentially dangerous signed to unsigned conversion
We make sure to never pass a negative `rlen` as size to memcpy(). See
also <https://bugs.php.net/bug.php?id=73280>.

Patch provided by Emmanuel Law.
2016-10-12 11:15:32 +02:00
Christoph M. Becker ca2b34e1f8 Fix #329: GD_BILINEAR_FIXED gdImageScale() can cause black border
We're passing `pixel1` as default color to `getPixelOverflow*()` for
pixels which may be outside the valid bounds. `pixel1` is supposed to
be always valid due to the fixed arithmetic's round towards zero
behavior.
2016-10-10 12:45:13 +02:00
Christoph M. Becker 77c8d359bb Fix #330: Integer overflow in gdImageScaleBilinearPalette()
The color components are supposed to be in range 0..255, so we must not
cast them to `signed char`, what can be the default for `char`.
2016-10-10 11:05:27 +02:00
Christoph M. Becker b6b44d962d Document that gdImageScale() does not yet support GD_WEIGHTED4 2016-10-09 18:21:31 +02:00
Christoph M. Becker 0c0cd18aff Revert "Fix #328: gdImageScale() with GD_WEIGHTED4 always returns NULL"
This reverts commit 0809c9f644.
2016-10-09 18:17:03 +02:00
Christoph M. Becker 0809c9f644 Fix #328: gdImageScale() with GD_WEIGHTED4 always returns NULL
Actually, there is no special case implementation for GD_WEIGHTED4
interpolation yet, so we must not pretend there would.
2016-10-09 16:25:07 +02:00
Christoph M. Becker 1f3f82d901 Document cropping stuff 2016-10-09 12:46:31 +02:00
Christoph M. Becker 1458f8765c Support writing lossless WebP
Lossless WebP is a rather interesting alternative to PNG, and already
supported by `gdImageCreateFromWebp*()`, so we add support for
`gdImageWebp*()`, too.

We can stick with the existing API, using the quality parameter to
request lossless encoding if it is set to `gdWebpLossless`, which we
define to `PHP_INT` (to avoid adding a new dependency to gd.h, we hard-
code the value – we're assuming `sizeof(int)==4` anyway).
2016-10-09 00:47:05 +02:00
Christoph M. Becker 4ebdb483e4 Document gdImageCompare() 2016-10-06 18:28:46 +02:00
Christoph M. Becker b697bf74db Document cloning, copying, scaling and interpolation 2016-10-06 15:50:16 +02:00
Christoph M. Becker 1b6564cdc8 Fix 321: Null pointer dereferences in gdImageRotateInterpolated
We let gdImageRotateInterpolated() fail early, if `src` is NULL.
2016-10-06 14:20:24 +02:00
Christoph M. Becker 65d40f5aa5 Fix #319: gdImageRotateInterpolated can have wrong background color
We backport the fix for <https://bugs.php.net/65070>, and also the fix for
<https://bugs.php.net/70976> which was introduced by fixing 65070.
2016-10-03 16:19:19 +02:00
Christoph M. Becker ddf3b493f1 Fix color quantization documentation 2016-10-03 10:26:42 +02:00
Christoph M. Becker 9a43a7b3fd Test and document the effects (aka. alpha blending modes) 2016-10-02 18:29:28 +02:00
Christoph M. Becker d6d2dec0fb Test and document gdImageFlip*() 2016-10-02 14:36:09 +02:00
Christoph M. Becker ddddd0a2ba Improve anti-aliased drawing related docs 2016-10-02 11:54:36 +02:00
Christoph M. Becker 30453e94b2 Test and document filling behavior of self-intersecting polygons 2016-10-01 20:03:14 +02:00
Christoph M. Becker 7f7a7d8eca Fix #315: Single-point gdImageAALine() is invisible
We're treating a single-pointed gdImageAALine() as we treat vertical and
horizontal gdImageAALines(); namely, we draw it non-antialiased.
2016-10-01 01:43:59 +02:00
Christoph M. Becker c3cf674cb4 Fix overflow checks
We check for the proper sizeofs and add the additional sx*sy check for
gdImageCreate(), which serves as a quick check for totally oversized images.
2016-09-30 17:37:00 +02:00
Christoph M. Becker 3e8b5c5ee2 Test and document some filter functions 2016-09-27 13:34:18 +02:00
Christoph M. Becker 0ef4df3e16 Fix GD2 format documentation
We must not forget the chunk headers.
2016-09-24 14:02:11 +02:00
Christoph M. Becker bb1998a16e Fix #309: gdImageGd2() writes wrong chunk sizes on boundaries 2016-09-23 18:29:52 +02:00
Christoph M. Becker 25e18ebce8 Improve documentation of truecolor to palette conversion 2016-09-21 14:14:27 +02:00
Christoph M. Becker 408ea5e5c3 Fix #307: GD_QUANT_NEUQUANT fails to unset trueColor flag
Before we copy the quantized palette image onto the original image, we have
to mark the latter as palette image. We also have to free the allocated
truecolor pixels; free_truecolor_image_data() does all that for us.
2016-09-21 12:42:49 +02:00
Christoph M. Becker 096f843e85 Revert "Fix #307: GD_QUANT_NEUQUANT fails to unset trueColor flag"
This reverts commit a74909b9a4.
2016-09-21 00:29:22 +02:00
Christoph M. Becker a74909b9a4 Fix #307: GD_QUANT_NEUQUANT fails to unset trueColor flag
We must unset the trueColor image after converting it; gdImageCopy() wont't
(rightly) do that for us.
2016-09-21 00:15:47 +02:00
Christoph M. Becker 40bec0f38f Merge branch 'pull-request/296' 2016-09-16 10:54:34 +02:00
Christoph M. Becker 0423df1131 Improve documentation 2016-09-15 23:36:49 +02:00
Christoph M. Becker 466d440002 Improve documentation 2016-09-15 14:59:21 +02:00
Christoph M. Becker 8ca157f67e No, we don't HAVE_BUNDLED_GD
This is obviously a relict of PHP's bundled libgd, which we should remove.
And actually, the #ifdef isn't necessary anymore for PHP's bundled libgd
either, because it supports gdImageAlphaBlending().
2016-09-14 20:10:29 +02:00
Christoph M. Becker 4b840e8216 Fix #300: gdImageClone() assigns res_y = res_x
We fix the obvious typo in gdImageClone(), add a regression test and improve
related documentation.
2016-09-12 23:59:51 +02:00
Christoph M. Becker 2fe471d5d4 Fix #299: Regression regarding gdImageRectangle() with gdImageSetThickness()
We remove the special casing for "point" rectangles with thick!=1 altogether,
and restrict the special casing for "line" rectangles to thick==1. We move
this necessary special casing (it fixes issue #172) towards the bottom of the
function like it is in PHP's bundled libgd.
2016-09-12 22:08:19 +02:00
Christoph M. Becker 4e8a94d36d Test and document gdImageRectangle
We're especially having a look at the point ordering issue, see
<https://github.com/libgd/libgd/issues/177>.
2016-09-12 14:33:17 +02:00
Christoph M. Becker 4933e316f4 Document image accessor macros 2016-09-11 17:54:14 +02:00
Christoph M. Becker a59523038d Fix #297: gdImageCrop() converts palette image to truecolor image
When just cropping an image, we want to stick with the same image type.
2016-09-11 16:17:49 +02:00
trylab 2806adfdc2 Fix integer overflow in gdImageWebpCtx
Integer overflow can be happened in expression gdImageSX(im) * 4 *
gdImageSY(im). It could lead to heap buffer overflow in the following
code. This issue has been reported to the PHP Bug Tracking System. The
proof-of-concept file will be supplied some days later. This issue was
discovered by Ke Liu of Tencent's Xuanwu LAB.
2016-09-06 18:35:32 +08:00
Christoph M. Becker b95197edee Fix fontlist doc 2016-09-04 18:45:46 +02:00
Christoph M. Becker 7a3a2da3d9 Fix potential build error
Without JPEG support `in` is unused, and causes a build failure due to
`-Werror`.
2016-09-03 19:12:58 +02:00
Christoph M. Becker 24b4550fa8 Fix PHP bug #67325: imagetruecolortopalette: white is duplicated in palette
gdImageTrueColorToPalette() is sometimes wasteful by putting multiple white
color entries into the palette. This is caused by an obvious typo, where
to avoid a division by zero when `total` is zero, `count` is checked instead
of `total`.

We fix this issue, to improve the quality of the color quantization.
2016-09-03 17:48:03 +02:00
Christoph M. Becker 0bd7ec0560 Fix use-after-free vulnerability
Of course, we must not free `text` before we're finished with it.

As this issue affects master only, it is not a security issue.
2016-08-27 16:08:38 +02:00
Christoph M. Becker 59d077aeab Fix build failure for --without-fontconfig
If fontconfig support is disabled, the static functions font_pattern() and
useFontConfig() are never used. This can lead to build errors, and does so
with the current default settings `-Wall -Werror`. Therefore we ensure that
these functions are not compiled when they are not needed.
2016-08-27 11:49:40 +02:00
Christoph M. Becker c1804def24 Mark up code examples with (start|end code)
This makes the code better readable in the sources, and we get syntax
highlighting in the generated HTML wherever we want it (i.e. not necessarily
always as with `-hl all`).
2016-08-23 22:27:27 +02:00
Christoph M. Becker 4778a8a946 Document gdft.c and gdfx.c
We also remove the respective comments from the *private* gdfx.h.
2016-08-23 21:35:32 +02:00
Christoph M. Becker 4f8e26f2a4 Fix #290: TGA RLE decoding is broken
We make it work only, for now. Actually, it doesn't make sense that
`oTga::bitmap` is an `int *` as we're storing only bytes there. If this
will be changed, we can even get rid of the `conversion_buffer` in
`read_image_tga` altogether, and read the image data into the
`decompression_buffer` (if RLE'd) or the `tga->bitmap` (if uncompressed)
directly.
2016-08-16 14:27:23 +02:00
Christoph M. Becker 88302603ef Fix unnecessary non NULL checks
Coverity rightly complains that `tmp_img` is checked for being `!= NULL`,
*after* it has been dereferenced[1]. Actually, the `NULL` check is not
necessary at all. To be on the safe side, we assert that `src != NULL` when
`gdImageScaleTwoPass()` has been called.

[1] <https://scan8.coverity.com/reports.htm#v30161/p11047/fileInstanceId=12793299&defectInstanceId=4423754>
2016-08-15 18:16:12 +02:00
Christoph M. Becker 09090c1256 Fix #289: Passing unrecognized formats to gdImageGd2 results in corrupted files
We must not apply the format correction twice for truecolor images.
2016-08-15 17:49:40 +02:00
Christoph M. Becker 5ee392d6e8 First stab at documenting the GD and GD2 image formats 2016-08-14 20:01:19 +02:00
Christoph M. Becker 4143073c88 Improve documentation of built-in fonts and their handling 2016-08-14 17:31:54 +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
Mike Frysinger b7a01fe6e3 gdft: fix build when freetype is disabled
In file included from gdft.c:20:0:
entities.h:17:4: error: 'entities' defined but not used [-Werror=unused-variable]

gdft.c:1741:15: error: 'font_path' defined but not used [-Werror=unused-function]
 static char * font_path(char **fontpath, char *name_list)
2016-08-10 13:35:08 +08:00
Mike Frysinger 9d26490ed1 gd2: fix build when zlib is disabled
gd_gd2.c: In function 'gdImageGd2Ptr':
gd_gd2.c:1122:1: error: control reaches end of non-void function [-Werror=return-type]
2016-08-10 13:26:20 +08:00
Christoph M. Becker 9b8ae7e221 Fix #280: gdImageWebpEx() `quantization` parameter is a misnomer
We therefore change the name to `quality`.
2016-08-05 12:53:18 +02:00
Christoph M. Becker 4d9459678f Actually document gdFree() 2016-08-03 16:16:29 +02:00
Christoph M. Becker 5cd8336c26 Publish all gdImageCreateFromWebp*() functions and gdImageWebpCtx()
These have already been BGD_DECLARE'd in gd.h, so we also do so in the actual
sources. While we're at it, we also add some documentation.
2016-08-03 15:41:17 +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 28440a4087 Remove superfluous if statement 2016-07-23 19:16:14 +02:00
Christoph M. Becker f101380bc6 Fix copy&paste error in gdImageScaleBicubicFixed() 2016-07-23 17:51:21 +02:00
Mike Frysinger d304360411 build: sync libgd source lists
The cmake build was missing gd_color_match.c which meant the library
didn't export the gdImageColorMatch function.  Sync the two lists in
the autotools and cmake files to make this easier to check.  Listing
header files in autotools source lists isn't a problem.
2016-07-22 18:12:48 +05:30
Mike Frysinger c78ae3e4d6 cmake: add visibility support #260
This makes sure we don't export symbols in libgd.so that we shouldn't.

We now assume that, if you're using gcc, you're using at least version
3.3 as that's the first to support the visibility attribute.  We can
wait to see if anyone complains before worrying about older ones.
2016-07-22 18:12:48 +05:30
Mike Frysinger 5090a9ebf7 cmake: allow static libs to be disabled
The standard behavior in distros nowadays is to build shared libs and
omit static libs.  Split the build knobs in cmake to support this.  It
also matches what's available with the autotools build.
2016-07-22 15:09:04 +05:30
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
Christoph M. Becker 8b7e76dd37 Fix typo introduced in 0dd1706 2016-07-20 13:27:30 +02:00
Pierre Joye 0dd1706c14 possible null deref 2016-07-20 17:00:16 +07:00
Pierre Joye e29a140290 revert, color is unsigned, <0 never happened 2016-07-20 16:40:17 +07:00
Pierre Joye bb16ba0297 Merge branch 'master' of github.com:libgd/libgd 2016-07-20 16:19:44 +07:00
Pierre Joye 7dfd79bbca improve color check for CropThreshold 2016-07-20 16:19:12 +07:00
Christoph M. Becker b4f985a11d Merge branch 'pull-request/262' 2016-07-19 13:56:49 +02:00
Christoph M. Becker a212f60114 Merge branch 'pull-request/261' 2016-07-19 12:13:18 +02:00
Pierre Joye b263053eac Merge branch 'master' of github.com:libgd/libgd 2016-07-19 17:07:17 +07:00
Pierre Joye 7a28c23589 fix possible OOB or OOM in gdImageScale, reported by Secunia (CVE 2016-6207) 2016-07-19 17:05:54 +07:00
Christoph M. Becker 71f2ff370e Fix #264: TGA warning coverity
We fix the unintended sign extension issue #150385 by declaring encoded_pixels
as int, and the logical vs. bitwise operator issue #150382 by using the
proper operator.
2016-07-19 11:41:46 +02:00
Pierre Joye f60ec7a546 fix possible OOB or OOM in gdImageScale, reported by Secunia (CVE 2016-6207) 2016-07-19 16:30:52 +07:00
Pierre Joye ff9113c80a fix possible OOB or OOM in gdImageScale, reported by Secunia (CVE 2016-6207) 2016-07-19 15:57:08 +07:00
Pierre Joye d325888a9f fix possible OOB or OOM in gdImageScale, reported by Secunia (CVE 2016-6207) 2016-07-19 15:25:47 +07:00
Pierre Joye add4733944 Merge branch 'master' of github.com:libgd/libgd 2016-07-19 14:46:08 +07:00
Pierre Joye 0dd40abd6d fix possible OOB or OOM in gdImageScale, reported by Secunia (CVE 2016-6207) 2016-07-19 14:45:56 +07:00
Pierre Joye d818ff9391 Merge branch 'master' of github.com:libgd/libgd 2016-07-19 14:38:59 +07:00
Pierre Joye 118fc7098b php bug 72519, invalid color index for transparent color can lead to OOB 2016-07-19 14:38:26 +07:00
Christoph M. Becker e7e20d67d7 No pixel of a filled arc must ever be drawn multiple times
Otherwise we get artifacts regarding transparency. That happens with the
current implementation of gdImageFilledArc() unless gdChord or gdNoFill
are set. When gdPie is set, however, the filled arc is drawn in wedges,
which are polygons of three points, and so some overlap is natural.

To resolve the issue, we stick with the current algorithm of calculating the
wedges, but instead of drawing each polygon separately, we put the *relevant*
points in a large array, and draw a single polygon. That also is supposed to
improve the performance considerably.

Note that this modification will change the results when gdImageSetStyle()
or gdImageSetBrush() are used, but we believe that this modification is
also an improvement in this regard, even though it still might not make much
sense to use these functions with gdImageFilledArc().
2016-07-17 18:41:17 +02:00
Christoph M. Becker 9fd6021e12 Fix #252: gd_error() garbles variable arguments
Currently gd_error() forwards to gd_error_ex(). However, both functions
accept a variable number of arguments, and simply forwarding the va_list
isn't portable, see <http://c-faq.com/varargs/handoff.html>. This article
also describes the usual workaround, namely to let the second function
accept a va_list instead of variable number of arguments.

We do so by introducing a static helper, what does not affect API/ABI
compatibility.
2016-07-17 14:53:42 +02:00
Ondřej Surý ff0234f4da Proper fix for #248 2016-07-15 09:43:45 +02:00
Ondřej Surý 981060efd6 bug #248, fix Out-Of-Bounds Read in read_image_tga 2016-07-14 10:39:41 +02:00
Christoph M. Becker cb1a0b7e54 Unsupported TGA bpp/alphabit combinations should error gracefully
Currently, only 24bpp without alphabits and 32bpp with 8 alphabits are
really supported. All other combinations will be rejected with a warning.
2016-07-13 00:43:10 +02:00
Christoph M. Becker 076e0d19d7 Revert "Unsupported TGA bpp/alphabit combinations should error gracefully"
This reverts commit 10ef1dca63.

There are build errors, so we revert for now.
2016-07-12 22:09:13 +02:00
Christoph M. Becker 10ef1dca63 Unsupported TGA bpp/alphabit combinations should error gracefully
Currently, only 24bpp without alphabits and 32bpp with 8 alphabits are
really supported. All other combinations will be rejected with a warning.
2016-07-12 20:46:33 +02:00
Ondřej Surý ead349e998 Fix #247, A read out-of-bands was found in the parsing of TGA files (CVE-2016-6132) 2016-07-12 16:11:51 +02:00
Mike Frysinger 973cac8f3f Merge pull request #246 from khalidalqassabi/raqm
Add complex text layout support
2016-06-30 08:35:55 -04:00
Khalid Alqassabi 1dbccb737c Add complex text layout support
This pull request (based on Asma's works) adds support for languages that require [complex text
layout](https://en.wikipedia.org/wiki/Complex_text_layout).

We are using [libraqm](https://github.com/HOST-Oman/libraqm), a small source
code-only library that wraps FriBidi (for bidirectional text support) and
HarfBuzz (for text shaping), and does proper BiDi and script itemization.

The CTL support is enabled by default but can be disabled at compiling time,
and we provide a fallback function that uses your original code without CTL
support.
2016-06-30 13:19:25 +04:00
Pierre Joye a6a0e7feab fix php bug 72339 (CVE-2016-5766), Integer Overflow in _gd2GetHeader() resulting in heap overflow. Sync with php's sync 2016-06-29 09:36:26 +07:00
Pierre Joye aba3db8ba1 fix php bug 72339 (CVE-2016-5766), Integer Overflow in _gd2GetHeader() resulting in heap overflow 2016-06-28 16:23:42 +07:00
Pierre Joye a0f9f8f7bd fix php 72494, CID 149753, color is unsigned int, remove useless <0 comparison 2016-06-27 11:43:34 +07:00
Pierre Joye 1ccfe21e14 fix php 72494, invalid color index not handled, can lead to crash 2016-06-27 11:41:40 +07:00
Pierre Joye 89520807f1 Merge branch 'GD-2.2'
* GD-2.2:
  fix CID 95839
  update
2016-06-24 09:45:08 +07:00
Pierre Joye 68a9c79e7c fix CID 95839 2016-06-24 09:44:44 +07:00
Pierre Joye 7a661d2de6 update 2016-06-24 09:15:38 +07:00
Pierre Joye 81888a70b0 update 2016-06-24 09:13:12 +07:00
Pierre Joye 3ac1d291e3 Merge branch 'GD-2.2'
* GD-2.2:
  fix CID 95839, fix logic and avoid duplicate code (and confusion)
  Add coverity status
2016-06-21 14:40:19 +07:00
Pierre Joye 9d4d314701 fix CID 95839, fix logic and avoid duplicate code (and confusion) 2016-06-21 14:00:32 +07:00
Pierre Joye a280b5c38d Merge branch 'GD-2.2'
* GD-2.2:
  fix CID 95837 duplicate code
2016-06-21 12:26:20 +07:00
Pierre Joye fa1e9b7612 fix CID 95837 duplicate code 2016-06-21 12:24:35 +07:00
Pierre Joye eafff87699 Merge branch 'GD-2.2'
* GD-2.2:
  fix CID 95837 duplicate code
  ensure null terminated string
  Fix #234: gdinterpolatedscale/gdTrivialResize is too slow
  ensure null terminated string
  Fix Coverity #95850: Structurally dead code
  Fix Coverity #102122: Unused value
  Fix Coverity #95850: Structurally dead code
  Fix Coverity #102122: Unused value
  Fix PHP bug #64641: imagefilledpolygon doesn't draw horizontal line
2016-06-21 12:17:46 +07:00
Pierre Joye f3b17253cb fix CID 95837 duplicate code 2016-06-21 12:17:26 +07:00
Pierre Joye 9f28c16ee0 ensure null terminated string 2016-06-21 10:40:06 +07:00
Pierre Joye 8757e32181 ensure null terminated string 2016-06-21 10:30:15 +07:00
Pierre Joye 292103e750 Merge branch 'master' of github.com:libgd/libgd 2016-06-21 10:21:01 +07:00
Christoph M. Becker cdbb81a07a Fix Coverity #95850: Structurally dead code
We slightly refactor the code to not use an else clause at all, what also
makes the code cleaner.

(cherry picked from commit 832c1ba791)
2016-06-21 00:28:36 +02:00
Christoph M. Becker 5eeb608db2 Fix Coverity #102122: Unused value
Apparently, that's a leftover from the "mode_mono fix from Giuliano Pochini".

(cherry picked from commit 327bf3d8b1)
2016-06-21 00:28:35 +02:00
Christoph M. Becker 832c1ba791 Fix Coverity #95850: Structurally dead code
We slightly refactor the code to not use an else clause at all, what also
makes the code cleaner.
2016-06-21 00:23:02 +02:00
Christoph M. Becker 327bf3d8b1 Fix Coverity #102122: Unused value
Apparently, that's a leftover from the "mode_mono fix from Giuliano Pochini".
2016-06-21 00:18:46 +02:00