[php-src] PR #17678: Prevent unsigned overflow in php_handle_swc()
| From: | cmb69 | Date: | Mon, 03 Feb 2025 12:01:08 +0000 |
| Subject: | [php-src] PR #17678: Prevent unsigned overflow in php_handle_swc() | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-30640@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/17678
Author: cmb69
The multiplication of
ZSTR_LEN(bufz) with the factor can easily overflow
on LLP64 architectures, causing a smaller buf to be allocated than expected. While
there are no security implications, calling uncompress() with the small buffer cannot
be successful (Z_BUF_ERROR). We avoid such superfluous calls by bailing out of the
loop early in case of an overflow condition.
Note that safe_emalloc() would not help here, since that will not prevent 32bit
unsigned overflow on 64bit architectures.