Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
linux-user: Fix signed math overflow in brk() syscall
Fix the math overflow when calculating the new_malloc_size. new_host_brk_page and brk_page are unsigned integers. If userspace reduces the heap, new_host_brk_page is lower than brk_page which results in a huge positive number (but should actually be negative). Fix it by adding a proper check and as such make the code more readable. Signed-off-by: Helge Deller <deller@gmx.de> Tested-by: "Markus F.X.J. Oberhumer" <markus@oberhumer.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Fixes: 86f0473 ("linux-user: Fix brk() to release pages") Cc: qemu-stable@nongnu.org Buglink: upx/upx#683 (cherry picked from commit eac78a4) Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
- Loading branch information