diff --git a/NEWS b/NEWS index 003727afbfd..f73b2951540 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,9 @@ PHP NEWS - Curl: . Fixed bug GH-16723 (CURLMOPT_PUSHFUNCTION issues). (cmb) +- 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 a2c3e7d0de6..093daeac419 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -1366,7 +1366,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-- +