Skip to content

Commit f799f42

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #79067: gdTransformAffineCopy() may use unitialized values
2 parents f4aa086 + 2c58605 commit f799f42

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ PHP NEWS
3434
. Fixed bug #74170 (locale information change after mime_content_type).
3535
(Sergei Turchanov)
3636

37+
- GD:
38+
. Fixed bug #79067 (gdTransformAffineCopy() may use unitialized values). (cmb)
39+
3740
- Libxml:
3841
. Fixed bug #79029 (Use After Free's in XMLReader / XMLWriter). (Laruence)
3942

ext/gd/libgd/gd_interpolation.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2289,7 +2289,7 @@ int gdTransformAffineGetImage(gdImagePtr *dst,
22892289
* src_area - Rectangular region to rotate in the src image
22902290
*
22912291
* Returns:
2292-
* GD_TRUE if the affine is rectilinear or GD_FALSE
2292+
* GD_TRUE on success or GD_FALSE on failure
22932293
*/
22942294
int gdTransformAffineCopy(gdImagePtr dst,
22952295
int dst_x, int dst_y,
@@ -2346,7 +2346,10 @@ int gdTransformAffineCopy(gdImagePtr dst,
23462346
end_y = bbox.height + abs(bbox.y);
23472347

23482348
/* Get inverse affine to let us work with destination -> source */
2349-
gdAffineInvert(inv, affine);
2349+
if (gdAffineInvert(inv, affine) == GD_FALSE) {
2350+
gdImageSetInterpolationMethod(src, interpolation_id_bak);
2351+
return GD_FALSE;
2352+
}
23502353

23512354
src_offset_x = src_region->x;
23522355
src_offset_y = src_region->y;

ext/gd/libgd/gd_matrix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ int gdAffineApplyToPointF (gdPointFPtr dst, const gdPointFPtr src,
5555
* <gdAffineIdentity>
5656
*
5757
* Returns:
58-
* GD_TRUE if the affine is rectilinear or GD_FALSE
58+
* GD_TRUE on success or GD_FALSE on failure
5959
*/
6060
int gdAffineInvert (double dst[6], const double src[6])
6161
{

ext/gd/tests/bug79067.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Bug #79067 (gdTransformAffineCopy() may use unitialized values)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('gd')) die('skip gd extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
$matrix = [1, 1, 1, 1, 1, 1];
10+
$src = imagecreatetruecolor(8, 8);
11+
var_dump(imageaffine($src, $matrix));
12+
?>
13+
--EXPECT--
14+
bool(false)

0 commit comments

Comments
 (0)