Commit graph

226 commits

Author SHA1 Message Date
David Carlier
4d7d01d18e
Fix GH-17772: imagepalettetotruecolor segfault on invalid truecolor pixel.
close GH-17777
2025-02-14 15:28:33 +00:00
Christoph M. Becker
2c658f422d
Fix GH-17349: Tiled truecolor filling looses single color transparency
This is porting the relevant part of a previous upstream commit[1] to
align the behavior of our bundled libgd with upstream.  It should be
noted that this only works if the image actually has a transparent
color.

[1] <4770e2b2d5>

Closes GH-17351.
2025-01-04 14:53:18 +01:00
Michael Voříšek
2c3dfe5160
Fix gdAlphaMax limit typo
Closes GH-7410.
2021-09-23 23:16:40 +02:00
Christoph M. Becker
526407ca35
Fix #53580: During resize gdImageCopyResampled cause colors change
We port the upstream fix[1], and also revert commit a3383ac3d7[2] which
is now obsolete, and also not part of libgd.  Especially the change to
gd.png.c was at best a half-baked optimization.

[1] <a24e96f019>
[2] <a3383ac3d7>

Closes GH-7402.
2021-08-26 18:38:17 +02:00
Christoph M. Becker
c565555f03
Fix #51498: imagefilledellipse does not work for large circles
We backport the respective upstream fix[1].

[1] <ace7fd88dc>

Closes GH-7329.
2021-08-03 16:17:47 +02:00
Christoph M. Becker
5dd1877ca1 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix potential integer overflow detected by oss-fuzz
2020-08-24 17:36:50 +02:00
Christoph M. Becker
74de17f2ea Fix potential integer overflow detected by oss-fuzz
We port the respective fix from upstream[1].

[1] <9ed642764c>
2020-08-24 17:35:04 +02:00
Nikita Popov
0849a621fd Fix abs(long) warnings in gd.c
I'm fixing this using (int) casts instead of labs() because this is
what upstream GD does.
2019-06-11 16:50:25 +02:00
Nikita Popov
7207110362 Fix uninit warning in gd.c
This matches the upstream implementation.
2019-04-12 16:03:01 +02:00
Nikita Popov
9d663cba1a Fix libgd warnings 2019-04-11 15:54:09 +02:00
Christoph M. Becker
26b5aa8584 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix #73614: gdImageFilledArc() doesn't properly draw pies
2019-01-16 20:22:37 +01:00
Christoph M. Becker
61cfa34e11 Fix #73614: 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.

This fix is a port of libgd/libgd@1406b1a.

[1] <https://bugs.php.net/bug.php?id=43828>
2019-01-16 20:10:04 +01:00
Gabriel Caruso
9e4d590b19
Remove extra semicolons 2018-07-25 21:47:04 -03:00
Christoph M. Becker
ab592df5dd Merge branch 'PHP-7.2'
* PHP-7.2:
  Fix #52070: imagedashedline() - dashed line sometimes is not visible
2018-03-30 19:39:44 +02:00
Christoph M. Becker
76f421dd3a Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fix #52070: imagedashedline() - dashed line sometimes is not visible
2018-03-30 19:29:10 +02:00
Christoph M. Becker
9c37d95627 Fix #52070: imagedashedline() - dashed line sometimes is not visible
We finally remove the inadvertent leftover from the synchronization
with GD 2.0.12.
2018-03-30 19:22:23 +02:00
Christoph M. Becker
eeda55cb3b Merge branch 'PHP-7.2'
* PHP-7.2:
  Fix #76041: null pointer access crashed php
2018-03-02 17:21:04 +01:00
Christoph M. Becker
d83467d70b Fix #76041: null pointer access crashed php
We must not draw anti-aliased lines on palette images, because that is
not supported by `gdImageSetAAPixelColor()` and it wouldn't make much
sense to support it, due to the limitation to at most 256 colors.
2018-03-02 17:18:45 +01:00
Gabriel Caruso
6400264856 Trailing whitespaces
Signed-off-by: Gabriel Caruso <carusogabriel34@gmail.com>
2018-01-03 14:38:00 +01:00
Anatol Belski
a75827b4f9 Merge branch 'PHP-7.1'
* PHP-7.1:
  Fixed bug #73418 Integer Overflow in "_php_imap_mail" leads to crash
  Fixed bug #73418 Integer Overflow in "_php_imap_mail" leads to crash
  Fix #72696: imagefilltoborder stackoverflow on truecolor images
  Fix #72482: Ilegal write/read access caused by gdImageAALine overflow
  Fix bug #73144 and bug #73341 - remove extra dtor
  remove unreferenced var came in with merge
  Fix bug #73331 - do not try to serialize/unserialize objects wddx can not handle
  Fix #72696: imagefilltoborder stackoverflow on truecolor images
  Fix #72482: Ilegal write/read access caused by gdImageAALine overflow
  fix version
  set versions
  Fix bug #73144 and bug #73341 - remove extra dtor
  Fix bug #73331 - do not try to serialize/unserialize objects wddx can not handle
2016-11-08 11:16:55 +01:00
Christoph M. Becker
5693474997 Fix #72696: imagefilltoborder stackoverflow on truecolor images
We must not allow negative color values be passed to
gdImageFillToBorder(), because that can lead to infinite recursion
since the recursion termination condition will not necessarily be met.

(cherry picked from commit 863d37ea66)
2016-11-01 13:07:37 +01:00
Christoph M. Becker
1b5543b8ab Fix #72482: Ilegal write/read access caused by gdImageAALine overflow
Instead of rolling our own bounds check we use clip_1d() as it's done
in gdImageLine() and in external libgd. We must not pass the image
width and height, respectively, but rather the largest ordinate value
that is allowed to be accessed, i.e. width-1 and height-1,
respectively.

(cherry picked from commit 6499581af7)
2016-11-01 13:03:41 +01:00
Christoph M. Becker
0f49aa3287 Merge branch 'pull-request/2151' 2016-10-17 10:37:38 +02:00
Anatol Belski
fa45124138 fix syslog interference 2016-10-13 14:40:37 +02:00
Christoph M. Becker
432e16cb58 Unify error handling of bundled and external libgd
There's no need anymore to call an own error handler directly. Instead we
register our error handler and call libgd's error functions (which will
forward). We do this regardless of compiling with the bundled or an external
libgd.
2016-10-07 01:13:49 +02:00
Christoph M. Becker
2a305b38b7 Implement request #33066: Add GD Image Function gdImageOpenPolygon()
gdImageOpenPolygon() has been introduced with líbgd 2.0.29, so we finally
add a PHP binding for it, and port the respective libgd functionality to
PHP's bundled libgd.
2016-10-02 20:27:58 +02:00
Christoph M. Becker
82a8e57f37 Add support for gdEffectMultiply
gdLayerMultiply() has been introduced in libgd 2.1.1, and as such would have
been already available for imagelayereffect() with a system libgd. We port
the respective code to the bundled libgd, and also make IMG_EFFECT_MULTIPLY
available to userland.
2016-10-02 19:10:13 +02:00
Christoph M. Becker
d0f14a4429 Switch to libgd anti-aliased drawing API
Instead of rolling our own in the bundled libgd, we use libgd's anti-aliased
drawing API. This way imageantialias() is also available, when built against
a system libgd.
2016-10-02 13:16:40 +02:00
Christoph M. Becker
0e38932d14 Merge branch 'PHP-7.1' 2016-10-01 00:02:05 +02:00
Christoph M. Becker
12967bc346 Merge branch 'PHP-5.6' into PHP-7.0 2016-09-30 23:54:18 +02:00
Christoph M. Becker
9acfb1a3a5 Fix #73213: Integer overflow in imageline() with antialiasing
We port the respective fixes <eca37d620>
and <837b7327> to our bundled libgd.
2016-09-30 23:38:13 +02:00
Christoph M. Becker
c60cdac636 Fix overflow checks
We check for the proper sizeofs, cf.
<c3cf674c>.
2016-09-30 20:15:15 +02:00
Christoph M. Becker
e3b889700b Remove further remains of the old antialiasing support
Curiously, while the external GD claims "just a few vestiges after switching
to the fast, memory-cheap implementation from PHP-gd", that stuff was still
in the bundled GD.
2016-09-30 17:04:37 +02:00
Christoph M. Becker
04400b19fc Remove basically effectless gdImageAABlend()
This had already be done for GD 2.0.26 as part of the improved antialiasing
support (<https://boutell.com/gd/manual2.0.26.html#whatsnew2.0.26>).
2016-09-30 16:12:47 +02:00
Christoph M. Becker
be30c34fb8 Sync with libgd wrt. compilation units
* integrate gd_arc.c into gd.c (as of gd-2.1.0-alpha1)
 * rename gd_color.c to gd_color_match.c (as of gd-2.1.0-alpha1)
 * remove mathmake.c (as of GD_2_0_34RC1)
 * rename xbm.c to gd_xbm.c (as of gd-2.1.0-alpha1)
2016-09-20 00:34:19 +02:00
Christoph M. Becker
932c20fb8d Port variable image resolution support from libgd 2.1.0
The PHP binding for this feature will be submitted as a separate PR.
2016-09-19 19:00:58 +02:00
Christoph M. Becker
77ba2483d9 Port gdImageSetStyle() overflow check from libgd 2.0.29 2016-09-19 16:56:07 +02:00
Christoph M. Becker
04b166a6c5 Removed unused function
The earlier gdAlphaBlend() has been replaced with commit 1286d9e2, and has
been renamed to gdAlphaBlendOld(). The old function is, however, not used,
and after more than 9 years we're pretty sure we won't need it anymore.
2016-09-15 13:04:30 +02:00
Christoph M. Becker
abb90fbc34 Refactor according to libgd
Cf. <a3016ad0>.
2016-09-12 22:37:32 +02:00
Christoph M. Becker
4c68fc5392 Merge branch 'PHP-5.6' into PHP-7.0 2016-08-21 17:45:49 +02:00
Christoph M. Becker
d65adac2be Fix #72913: imagecopy() loses single-color transparency on palette images
The proper code to handle true-color to palette copies is already contained
in gdImageCopy(), so we can simply remove the buggy duplicated code.
2016-08-21 17:39:23 +02:00
Christoph M. Becker
7a36056d6c Merge branch 'PHP-5.6' into PHP-7.0 2016-08-21 16:15:22 +02:00
Christoph M. Becker
9eb5bbd8bd Fix #66005: imagecopy does not support 1bit transparency on truecolor images
We must not copy transparent pixels, see
<daac285c>.
2016-08-21 16:08:57 +02:00
Stanislav Malyshev
df5ee7bc25 Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
  Improve fix for #72520
  #72482, revert for 5.6 for now

Conflicts:
	ext/zip/zip_stream.c
2016-07-19 22:38:35 -07:00
Pierre Joye
e8b768dd92 Merge branch 'PHP-5.6' of git.php.net:php-src into PHP-5.6 2016-07-20 00:18:56 +07:00
Pierre Joye
9cc0a5a9a9 #72482, revert for 5.6 for now 2016-07-20 00:18:25 +07:00
Christoph M. Becker
8466155ff5 Merge branch 'PHP-5.6' into PHP-7.0 2016-07-19 17:41:16 +02:00
Christoph M. Becker
828f911efd Fix #43828: broken transparency of imagearc for truecolor in blendingmode
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().

The respective fix for libgd is
<e7e20d6>.
2016-07-19 17:38:26 +02:00
Pierre Joye
77a71cba20 Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
  #72482, Ilegal write/read access caused by gdImageAALine overflow
2016-07-19 19:34:51 +07:00
Pierre Joye
b25009fc2c #72482, Ilegal write/read access caused by gdImageAALine overflow 2016-07-19 19:34:07 +07:00