mirror of
https://github.com/google/brotli.git
synced 2026-07-08 17:56:58 +00:00
Possible Integer overflow #440
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @BruceYChien on GitHub (Nov 2, 2022).
Hi,
When I look at the source code of brotli/c/enc/compress_fragment_two_pass.c line 463, it occurs to me that the insert might encounter integer overflow. As the variable "insert" is equal to (uint32_t)(ip_end - next_emit), the ip_end and next_emit is a pointer which might be 64 bit in 64 bit machine. In this case, the ip_end - next_emit might overflow to a small number when ip_end - next_emit is larger than the 32 bit max value. This might cause the memcpy to copy only partial value of the source "next_emit" to the dest "*literals".
@eustas commented on GitHub (Dec 29, 2022):
Will take a look at this soon. Thanks for the report.
@eustas commented on GitHub (Dec 29, 2022):
Initially:
In the loop
ipgrows, and sometimesnext_emitis assignedip. Consequently, difference is less thanblock_sizewhich is less thankCompressFragmentTwoPassBlockSize(128K).