Skip to content

Commit 2c2852a

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix GH-20622: imagestring/imagestringup overflow/underflow.
2 parents 175548e + 9f654de commit 2c2852a

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 8.4.17
44

5+
- GD:
6+
. Fixed bug GH-20622 (imagestring/imagestringup overflow). (David Carlier)
7+
58

69
18 Dec 2025, PHP 8.4.16
710

ext/gd/gd.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3023,7 +3023,8 @@ static void php_imagechar(INTERNAL_FUNCTION_PARAMETERS, int mode)
30233023
zend_long X, Y, COL;
30243024
zend_string *C;
30253025
gdImagePtr im;
3026-
int ch = 0, col, x, y, i, l = 0;
3026+
int ch = 0, col, i, l = 0;
3027+
unsigned int x, y;
30273028
unsigned char *str = NULL;
30283029
zend_object *font_obj = NULL;
30293030
zend_long font_int = 0;
@@ -3055,21 +3056,21 @@ static void php_imagechar(INTERNAL_FUNCTION_PARAMETERS, int mode)
30553056

30563057
switch (mode) {
30573058
case 0:
3058-
gdImageChar(im, font, x, y, ch, col);
3059+
gdImageChar(im, font, (int)x, (int)y, ch, col);
30593060
break;
30603061
case 1:
30613062
php_gdimagecharup(im, font, x, y, ch, col);
30623063
break;
30633064
case 2:
30643065
for (i = 0; (i < l); i++) {
3065-
gdImageChar(im, font, x, y, (int) ((unsigned char) str[i]), col);
3066+
gdImageChar(im, font, (int)x, (int)y, (int) ((unsigned char) str[i]), col);
30663067
x += font->w;
30673068
}
30683069
break;
30693070
case 3: {
30703071
for (i = 0; (i < l); i++) {
30713072
/* php_gdimagecharup(im, font, x, y, (int) str[i], col); */
3072-
gdImageCharUp(im, font, x, y, (int) str[i], col);
3073+
gdImageCharUp(im, font, (int)x, (int)y, (int) str[i], col);
30733074
y -= font->w;
30743075
}
30753076
break;

ext/gd/tests/gh20622.phpt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
GH-20622 (imagestring/imagestringup overflow/underflow)
3+
--EXTENSIONS--
4+
gd
5+
--FILE--
6+
<?php
7+
$im = imagecreate(64, 64);
8+
imagestringup($im, 5, 0, -2147483648, 'STRINGUP', 0);
9+
imagestring($im, 5, -2147483648, 0, 'STRING', 0);
10+
echo "OK";
11+
?>
12+
--EXPECT--
13+
OK

0 commit comments

Comments
 (0)