-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix 2 segfaults in the range() function #1677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Both segfaults occur due to accuracy lost when representing 64bit longs as doubles. The segfaults can be replicated with: range(PHP_INT_MIN + 513, PHP_INT_MIN); // Seg fault on line 2236 range(PHP_INT_MAX - 512, PHP_INT_MAX); // Seg fault on line 2249
4bc9886
to
36bc2fc
Compare
This caused a few tests to fail because a different error message was being output
|| (high == ZEND_LONG_MIN && low > -2) /* overflow check */ | ||
|| __calc_size > HT_MAX_SIZE /* the array size is too big */ | ||
) { | ||
php_error_docref(NULL, E_WARNING, "The supplied range exceeds the maximum array size: start=%ld end=%ld", high, low); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An appropriate sprintf format should be used for zend_long, please see UPGRADING INTERNALS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks.
ed1f449
to
5433534
Compare
73f14ad
to
8e4dd2f
Compare
8e4dd2f
to
62f379e
Compare
By using the calculated array size to determine the number of loop iterations, we no longer need to perform overflow checks in the loops
Dups with #1690 ? |
Per PR description these 2 PRs fix at least different bug-ids |
@jpauli Nope, the segfaults are in different places. |
Roger |
Superseded by PR #1695. |
Both segfaults occur due to accuracy lost when representing 64bit longs as
doubles.
The segfaults can be replicated with:
This fixes Bug #71132