Skip to content

Fix GH-25948: BMP height INT32_MIN invokes undefined behavior in abs() - #25952

Open
lazerg wants to merge 1 commit into
php:PHP-8.4from
lazerg:fix/gh-25948
Open

lazerg wants to merge 1 commit into
php:PHP-8.4from
lazerg:fix/gh-25948

Conversation

@lazerg

@lazerg lazerg commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

BMP stores a signed height, and php_handle_bmp() takes abs() of it to handle top-down images. A height of INT32_MIN has no positive counterpart, so abs() overflows (UBSan flags it) and getimagesize() reports a garbage size. Such a header is invalid, so it is now rejected and getimagesize() returns false.

Fixes #25948

@lazerg

lazerg commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

The Windows failure in socket_close_stream_resource.phpt is not from this change. It also fails on PHP-8.4 since 06712ae.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

1 participant