[php-src] PHP-8.6: ext/mbstring: assert that `mb_wchar_to_uuencode()` pointer write is in bounds (#23955)

From: Date: Mon, 28 Sep 2026 23:56:06 +0000
Subject: [php-src] PHP-8.6: ext/mbstring: assert that `mb_wchar_to_uuencode()` pointer write is in bounds (#23955)
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-141657@lists.php.net to get a copy of this message
Author: Daniel Scherzer (DanielEScherzer) Committer: GitHub (web-flow) Pusher: DanielEScherzer Date: 2026-09-28T16:56:03-07:00 Commit: https://github.com/php/php-src/commit/8906dc25186b0e3675ae0e2b57366b0cc7196cbc Raw diff: https://github.com/php/php-src/commit/8906dc25186b0e3675ae0e2b57366b0cc7196cbc.diff ext/mbstring: assert that mb_wchar_to_uuencode() pointer write is in bounds (#23955) Add a hardening assertion that when mb_wchar_to_uuencode() needs to update the length of the previous line, the location being written to is still part of the same overall output string (i.e. at or after the start of the buffer's str's value pointer, and before the end of the char array). Changed paths: M ext/mbstring/libmbfl/filters/mbfilter_uuencode.c Diff: diff --git a/ext/mbstring/libmbfl/filters/mbfilter_uuencode.c b/ext/mbstring/libmbfl/filters/mbfilter_uuencode.c index 600d019b9d49..896b95279717 100644 --- a/ext/mbstring/libmbfl/filters/mbfilter_uuencode.c +++ b/ext/mbstring/libmbfl/filters/mbfilter_uuencode.c @@ -287,6 +287,9 @@ static void mb_wchar_to_uuencode(uint32_t *in, size_t len, mb_convert_buf *buf, if (n_cached_bits) { len_byte -= (n_cached_bits == 2) ? 1 : 2; } + /* The byte we are writing to must be part of the same buffer */ + ZEND_ASSERT(len_byte >= (unsigned char *)ZSTR_VAL(buf->str)); + ZEND_ASSERT(len_byte < limit); *len_byte = MIN(bytes_encoded + len + (n_cached_bits ? (n_cached_bits == 2 ? 1 : 2) : 0), 45) + 32; if (n_cached_bits) {

« previous php.cvs (#141657) next »