Commit graph

101 commits

Author SHA1 Message Date
Christoph M. Becker
e4df0cbe1c
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix libgd 223: gdImageRotateGeneric() does not properly interpolate
2025-01-06 20:39:14 +01:00
Christoph M. Becker
12e4ee492b
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix libgd 223: gdImageRotateGeneric() does not properly interpolate
2025-01-06 20:38:34 +01:00
Christoph M. Becker
47683487f8
Fix libgd 223: gdImageRotateGeneric() does not properly interpolate
We port the respective upstream fix[1].  We only run the test against
bundled libgd, since external libgd may yield different results.

Cf. <2b26be874d>.

Closes GH-17380.
2025-01-06 20:37:23 +01:00
Christoph M. Becker
f55d6cc110
Internalize gdImageScale*() and gdImageRotate*() helpers
This is basically a port of the "Small code cleanup" commit[1].

We can now drop the superfluous checks for zero width/height.  These
have been introduced as fix for bug 72337[2], while the same issue had
a simpler fix for upstream[3], because the helper functions already
were internal.

[1] <e054be7d82>
[2] <https://bugs.php.net/72337>
[3] <77309c419c>
2025-01-03 14:26:36 +01:00
Niels Dossche
d7e7e2b338
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16559: UBSan abort in ext/gd/libgd/gd_interpolation.c:1007
2024-10-23 20:10:04 +02:00
Niels Dossche
e1e1e64a32
Fix GH-16559: UBSan abort in ext/gd/libgd/gd_interpolation.c:1007
The `uchar_clamp` function was backported from old code, this backports
it from new code.

Closes GH-16562.
2024-10-23 20:09:12 +02:00
David Carlier
7f1fd0646b
Merge branch 'PHP-8.3' into PHP-8.4 2024-10-07 13:05:41 +01:00
David Carlier
a2bdfeff4f
Fix GH-16257 imagescale underflow on RGB channels.
backport of 948bb0a5c2

close GH-16257
2024-10-07 13:05:05 +01:00
Peter Kokot
ba8633a9ce
Use fabsf() and floorf() unconditionally in bundled libgd (#13624)
These are available since C99 with math.h also on Windows, without
requiring checking. Upstream libgd uses floorf() unconditionally and
doesn't use fabsf().
2024-03-08 19:28:52 +01:00
Ben Morss
81f6d36c90 Add avif support to ext/gd
This backports avif support from upstream libgd into bundled libgd
and exposes the functionality through new imagecreatefromavif()
and imageavif() functions.

Closes GH-7026.

Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>
2021-06-10 12:32:30 +02:00
Christoph M. Becker
3f890635ae
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #81032: GD install is affected by external libgd installation
2021-05-14 12:28:36 +02:00
Christoph M. Becker
c455f49a6a
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81032: GD install is affected by external libgd installation
2021-05-14 12:26:40 +02:00
Flavio Heleno
28e7addb9d
Fix #81032: GD install is affected by external libgd installation
This PR replaces the bundled libgd includes from #include <foo.h> with
#include "foo.h" for gd-related headers to avoid including headers that
may be available in system directories instead of the expected local
headers.

Closes GH-6975.
2021-05-14 12:24:45 +02:00
George Peter Banyard
5caaf40b43
Introduce pseudo-keyword ZEND_FALLTHROUGH
And use it instead of comments
2021-04-07 00:46:29 +01:00
Christoph M. Becker
b7a55aaff2 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #79676: imagescale adds black border with IMG_BICUBIC
2020-06-12 14:09:16 +02:00
Christoph M. Becker
ff7fd3dc85 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79676: imagescale adds black border with IMG_BICUBIC
2020-06-12 14:07:43 +02:00
Christoph M. Becker
86e1f0ea11 Fix #79676: imagescale adds black border with IMG_BICUBIC
We have to loop over all image pixels to avoid the black border.  This
is also done in external libgd in `_gdScaleOneAxis` and `_gdScalePass`.
2020-06-12 14:05:54 +02:00
George Peter Banyard
ac89139773 Fix [-Wtype-limits] in bundled GD lib by using signed integers
As seen in the gdImageRotateBicubicFixed() function the same setup
occurs but it uses signed integers, therefore we use also use
signed integers in gdImageRotateBilinear()

Moreover, these two functions have been removed upstream in
bd6d2e101f
therefore we should also mimic upstream and remove them...

Thanks to @cmb69 for pointing it out.
2020-02-06 01:34:09 +01:00
Christoph M. Becker
03bd4333f6 Add imagegetinterpolation()
While `imagesetinterpolation()` is available as of PHP 5.5.0,
there is no according getter function, so users would have to track the
current interpolation method manually.

To remedy this, we introduce `imagegetinterpolation()` as thin wrapper
for `gdImageGetInterpolationMethod()` (which has been introduced with
libgd 2.1.1), and use `im->interpolation_id` as fallback for older
libgd.  Since our bundled libgd does not yet have this function, we add
it.

We also simplify the recently introduced bug79068.phpt, where it is
sufficient to check that the interpolation method has not been changed.
2020-01-14 18:25:27 +01:00
Christoph M. Becker
be0b94c220 Fix hypothetical segfault in gdTransformAffineCopy()
This has been reported to upstream[1], but since ext/gd never calls
`gdTransformAffineCopy()` for a palette image, it is not a bug for PHP.
Therefore we apply the fix to master only.

[1] <https://github.com/libgd/libgd/issues/586>
2020-01-06 13:25:11 +01:00
Christoph M. Becker
74b11e3315 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79068: gdTransformAffineCopy() changes interpolation method
2020-01-06 10:38:22 +01:00
Christoph M. Becker
4bec59f175 Fix #79068: gdTransformAffineCopy() changes interpolation method
We port
<9088591eae>.
2020-01-06 10:36:48 +01:00
Christoph M. Becker
f799f42ec8 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79067: gdTransformAffineCopy() may use unitialized values
2020-01-06 09:37:40 +01:00
Christoph M. Becker
2c5860517c Fix #79067: gdTransformAffineCopy() may use unitialized values
We port
<7a06c1669c>.
2020-01-06 09:35:13 +01:00
Peter Kokot
48abed7fd8 Use e.g. instead of less common f.e. [ci skip] 2019-07-09 17:53:46 +02:00
Nikita Popov
9b3b07cd26 Suppress shift UB in gd_itofx()
There doesn't seem to be a corresponding upstream fix for this.
2019-06-19 17:27:09 +02:00
Nikita Popov
e5411e17c7 Remove unused _setEdgePixel() and getPixelOverflowColorTC() functions 2019-06-11 16:59:12 +02:00
Nikita Popov
5c844c1d36 Fix fabs warning in gd_interpolation.c
Matches upstream code.
2019-06-11 16:57:24 +02:00
Christoph M. Becker
8c21ce5b2e Fix misleading variable type
We port libgd/libgd@0414bb2da0.
2019-01-11 00:21:44 +01:00
Christoph M. Becker
41c3e3d853 Remove unused variables and functions
We remove the unused variables altogether, and port
libgd/libgd@f50c24e467 to silence the
compiler warnings.
2019-01-10 18:00:27 +01:00
Christoph M. Becker
3f9ddeb122 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix #73281: imagescale(…, IMG_BILINEAR_FIXED) can cause black border
2019-01-10 16:27:43 +01:00
Christoph M. Becker
6b4cdbaade Fix #73281: imagescale(…, IMG_BILINEAR_FIXED) can cause black border
We port the upstream fixes for libgd/libgd#329 and libgd/libgd#224.
2019-01-10 16:11:23 +01:00
Christoph M. Becker
1e407256f2 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix #77272: imagescale() may return image resource on failure
2019-01-10 14:25:11 +01:00
Christoph M. Becker
772b1cb245 Fix #77272: imagescale() may return image resource on failure
`_gdScaleHoriz()` and `_gdScaleVert()` may fail, but don't signal
failure since they are void functions.  We change that according to
upstream libgd.

We also remove the unused `Scale()` function, which doesn't exist in
upstream libgd either, right away.
2019-01-10 14:05:09 +01:00
Stanislav Malyshev
e40027ef0f Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix #77369 - memcpy with negative length via crafted DNS response
  Fix more issues with encodilng length
  Fix #77270: imagecolormatch Out Of Bounds Write on Heap
  Fix bug #77380  (Global out of bounds read in xmlrpc base64 code)
  Fix bug #77371 (heap buffer overflow in mb regex functions - compile_string_node)
  Fix bug #77370 - check that we do not read past buffer end when parsing multibytes
  Fix #77269: Potential unsigned underflow in gdImageScale
  Fix bug #77247 (heap buffer overflow in phar_detect_phar_fname_ext)
  Fix bug #77242 (heap out of bounds read in xmlrpc_decode())
  Regenerate certs for openssl tests
2019-01-06 12:23:53 -08:00
Christoph M. Becker
dfd8237aec Fix #77269: Potential unsigned underflow in gdImageScale
Belatedly, we're porting the respective upstream patch[1].

[1] <60bfb401ad>
2019-01-06 11:38:46 -08:00
Gabriel Caruso
a5f1a585e6 Removed unused variables 2018-02-11 22:46:33 +01:00
Gabriel Caruso
6400264856 Trailing whitespaces
Signed-off-by: Gabriel Caruso <carusogabriel34@gmail.com>
2018-01-03 14:38:00 +01:00
Lior Kaplan
32e3d7b99e Define floorf if system doesn't have it (follow up for 22c48761)
floorf is checked in config.m4
2017-11-29 16:46:47 +01:00
Christoph M. Becker
22c487616f Fixed bug #65148 (imagerotate may alter image dimensions)
We apply the respective patches from external libgd, work around the
still missing `gdImageClone()`, and fix the special cased rotation
routines according to Pierre's patch
(https://gist.github.com/pierrejoye/59d72385ed1888cf8894a7ed437235ae).

We also cater to bug73272.phpt whose result obviously changes a bit.
2017-10-24 17:02:56 +02:00
Christoph M. Becker
e20a6b0213 Fixed bug #75139 (libgd/gd_interpolation.c:1786: suspicious if ?)
We back-port dd48286 even though
we cannot come up with a regression test, because the erroneous
condition appears to be impossible to trigger.

We also parenthesize the inner ternary operation to avoid confusion.
2017-09-02 00:04:02 +02:00
Christoph M. Becker
fc989fc6e7 Fix #73279: 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`.

Port of <77c8d359>.
2016-10-10 11:41:39 +02:00
Christoph M. Becker
88838dd282 Fix #68712: suspicious if-else statements 2016-07-23 19:29:43 +02:00
Christoph M. Becker
9fbd0c1ff1 Fix copy&paste errors in gd_interpolation.c
According to <f101380>.
2016-07-23 18:09:18 +02:00
Pierre Joye
48e76abadd improve fix #72558, free contribRow as well 2016-07-19 16:33:17 +07:00
Pierre Joye
df09515089 improve fix #72558, while (u>=0) with unsigned int will always be true 2016-07-19 15:51:43 +07:00
Stanislav Malyshev
f69362d212 Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
  Fix memory leak
2016-07-19 01:47:40 -07:00
Stanislav Malyshev
47d6ea6332 Fix memory leak 2016-07-19 01:47:27 -07:00
Stanislav Malyshev
4d0565b5ba Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
  fix #72519, possible OOB using imagegif
  fix #72512, invalid read or write for palette image when invalid transparent index is used
  Apparently some envs miss SIZE_MAX
  Fix tests
  Fix bug #72618: NULL Pointer Dereference in exif_process_user_comment
  Partial fix for bug #72613 - do not treat negative returns from bz2 as size_t
  Fix bug #72606: heap-buffer-overflow (write) simplestring_addn simplestring.c
  Fix for bug #72558, Integer overflow error within _gdContributionsAlloc()
  Fix bug #72603: Out of bound read in exif_process_IFD_in_MAKERNOTE
  Fix bug #72562 - destroy var_hash properly
  Fix bug #72533 (locale_accept_from_http out-of-bounds access)
  Fix fir bug #72520
  Fix for bug #72513
  CS fix and comments with bug ID
  Fix for HTTP_PROXY issue.
  add tests for bug #72512
  Fixed bug #72512 gdImageTrueColorToPaletteBody allows arbitrary write/read access
  Fixed bug #72479 - same as #72434

Conflicts:
	ext/bz2/bz2.c
	main/SAPI.c
	main/php_variables.c
2016-07-19 00:53:08 -07:00
Pierre Joye
928aecc002 fix #72512, invalid read or write for palette image when invalid transparent index is used
Conflicts:
	ext/gd/libgd/gd.c
2016-07-19 00:37:38 -07:00