Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent unsigned overflow in php_handle_swc() (GH-17678)
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.
- Loading branch information