Skip to content

Commit 6727f54

Browse files
authored
Port "gd2: use existing overflow2() rather than ad-hoc version" (#15090)
We port this modification[1] from libgd into our bundled libgd, because the change makes sense, and we want the code bases to stay in sync as close as possible. We also apply a quick fix to the respective test. [1] <libgd/libgd@f0a059b>
1 parent 8b6f14a commit 6727f54

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

ext/gd/libgd/gd_gd2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static int _gd2GetHeader(gdIOCtxPtr in, int *sx, int *sy, int *cs, int *vers, in
137137
GD2_DBG(gd_error("%d Chunks vertically", *ncy));
138138

139139
if (gd2_compressed(*fmt)) {
140-
if (*ncx <= 0 || *ncy <= 0 || *ncx > INT_MAX / *ncy) {
140+
if (overflow2(*ncx, *ncy)) {
141141
GD2_DBG(printf ("Illegal chunk counts: %d * %d\n", *ncx, *ncy));
142142
goto fail1;
143143
}

ext/gd/tests/bug73869.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ var_dump(imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . 'bug73869a.gd2'));
1414
var_dump(imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . 'bug73869b.gd2'));
1515
?>
1616
--EXPECTF--
17+
%A
1718
Warning: imagecreatefromgd2(): "%s" is not a valid GD2 file in %s on line %d
1819
bool(false)
1920

21+
%A
2022
Warning: imagecreatefromgd2(): "%s" is not a valid GD2 file in %s on line %d
2123
bool(false)

0 commit comments

Comments
 (0)