diff --git a/NEWS b/NEWS index bf6f7537d84..2b3b9e3f9c2 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,9 @@ PHP NEWS - FPM: . Fixed GH-16432 (PHP-FPM 8.2 SIGSEGV in fpm_get_status). (Jakub Zelenka) +- GD: + . Fixed GH-16776 (imagecreatefromstring overflow). (David Carlier) + - Hash: . Fixed GH-16711: Segfault in mhash(). (Girgias) diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 6b41efd949a..b1a9a333e1f 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -1323,7 +1323,7 @@ static int _php_ctx_getmbi(gdIOCtx *ctx) do { i = (ctx->getC)(ctx); - if (i < 0) { + if (i < 0 || mbi > (INT_MAX >> 7)) { return -1; } mbi = (mbi << 7) | (i & 0x7f); diff --git a/ext/gd/tests/gh16771.phpt b/ext/gd/tests/gh16771.phpt new file mode 100644 index 00000000000..232317cec11 --- /dev/null +++ b/ext/gd/tests/gh16771.phpt @@ -0,0 +1,10 @@ +--TEST-- +GH-16771 (UBSan abort in ext/gd/libgd/gd.c:1372) +--EXTENSIONS-- +gd +--FILE-- +