Skip to content

ext/standard: Fix sleep and usleep unsigned integer overflow#22619

Merged
LamentXU123 merged 2 commits into
php:masterfrom
LamentXU123:fix-overflow
Jul 6, 2026
Merged

ext/standard: Fix sleep and usleep unsigned integer overflow#22619
LamentXU123 merged 2 commits into
php:masterfrom
LamentXU123:fix-overflow

Conversation

@LamentXU123

@LamentXU123 LamentXU123 commented Jul 6, 2026

Copy link
Copy Markdown
Member

sleep(4294967296) actually sleep 0 seconds because of a unsigned int overflow bug, see here. This is also true in usleep

I target this to master as a fix that is classified as a stricter parsing. Now we throw ValueError instead.

p.s.: in Windows, the sleep function is implemented with SleepEx(t * 1000, TRUE) not php_sleep, phew, so we need to lower the threshold to UINT_MAX / 1000

Comment thread ext/standard/basic_functions.c Outdated
Comment thread ext/standard/basic_functions.c Outdated
@LamentXU123 LamentXU123 requested a review from Girgias July 6, 2026 17:56
@LamentXU123 LamentXU123 changed the title ext/standard: Fix sleep and usleep signed integer overflow ext/standard: Fix sleep and usleep unsigned integer overflow Jul 6, 2026
@LamentXU123 LamentXU123 merged commit 6beb089 into php:master Jul 6, 2026
18 checks passed
@LamentXU123 LamentXU123 deleted the fix-overflow branch July 6, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants