[php-src] PR #22432: Fix unsigned wrap in bzdecompress() output realloc at source_len UINT_MAX
| From: | iliaal | Date: | Wed, 24 Jun 2026 11:22:24 +0000 |
| Subject: | [php-src] PR #22432: Fix unsigned wrap in bzdecompress() output realloc at source_len UINT_MAX | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-36598@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22432
Author: iliaal
The input guard rejects only source_len > UINT_MAX, so source_len == UINT_MAX is permitted and
assigned to bzs.avail_out (unsigned int). The per-iteration realloc then computed bzs.avail_out+1 in
unsigned int arithmetic, which wraps to 0 at UINT_MAX, allocating no headroom while bz2 still
believes avail_out bytes are available at next_out, so the next decompress round writes past the
buffer. Compute the term as (size_t)bzs.avail_out + 1 so the increment is done in size_t and cannot
wrap, matching the (size_t) casts already on the same call. Triggering needs a ~4GB crafted input,
so there is no portable red/green test. Follow-up to the input guard added in #22242.