-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Fix GH-11876: ini_parse_quantity() accepts invalid quantities #11910
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--TEST-- | ||
Invalid INI quantities, base prefix followed by stuff eaten by strtoull() | ||
--EXTENSIONS-- | ||
zend_test | ||
--FILE-- | ||
<?php | ||
|
||
var_dump(zend_test_zend_ini_parse_quantity('0x0x12')); | ||
|
||
var_dump(zend_test_zend_ini_parse_quantity('0b+10')); | ||
var_dump(zend_test_zend_ini_parse_quantity('0o+10')); | ||
var_dump(zend_test_zend_ini_parse_quantity('0x+10')); | ||
|
||
var_dump(zend_test_zend_ini_parse_quantity('0b 10')); | ||
var_dump(zend_test_zend_ini_parse_quantity('0o 10')); | ||
var_dump(zend_test_zend_ini_parse_quantity('0x 10')); | ||
|
||
var_dump(zend_test_zend_ini_parse_quantity('0g10')); | ||
var_dump(zend_test_zend_ini_parse_quantity('0m10')); | ||
var_dump(zend_test_zend_ini_parse_quantity('0k10')); | ||
|
||
--EXPECTF-- | ||
Warning: Invalid quantity "0x0x12": no digits after base prefix, interpreting as "0" for backwards compatibility in %s on line %d | ||
int(0) | ||
|
||
Warning: Invalid quantity "0b+10": no digits after base prefix, interpreting as "0" for backwards compatibility in %s on line %d | ||
int(0) | ||
|
||
Warning: Invalid quantity "0o+10": no digits after base prefix, interpreting as "0" for backwards compatibility in %s on line %d | ||
int(0) | ||
|
||
Warning: Invalid quantity "0x+10": no digits after base prefix, interpreting as "0" for backwards compatibility in %s on line %d | ||
int(0) | ||
|
||
Warning: Invalid quantity "0b 10": no digits after base prefix, interpreting as "0" for backwards compatibility in %s on line %d | ||
int(0) | ||
|
||
Warning: Invalid quantity "0o 10": no digits after base prefix, interpreting as "0" for backwards compatibility in %s on line %d | ||
int(0) | ||
|
||
Warning: Invalid quantity "0x 10": no digits after base prefix, interpreting as "0" for backwards compatibility in %s on line %d | ||
int(0) | ||
|
||
Warning: Invalid quantity "0g10": unknown multiplier "0", interpreting as "0" for backwards compatibility in %s on line %d | ||
int(0) | ||
|
||
Warning: Invalid quantity "0m10": unknown multiplier "0", interpreting as "0" for backwards compatibility in %s on line %d | ||
int(0) | ||
|
||
Warning: Invalid quantity "0k10": unknown multiplier "0", interpreting as "0" for backwards compatibility in %s on line %d | ||
int(0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
seems to me could be interpreted/simplified slightly as :
if (UNEXPECTED(digits == str_end) || UNEXPECTED(digits != zend_ini_consume_quantity_prefix(digits, str_end)) { goto invalid_quantity; }
eventually even having a
const char *errmsg
so line 614 can be addressed too.unless I misread. What do you think ?
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.
The condition change makes sense, not sure I understand what you mean about line 614?
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.
Line like 614 is just displaying the wrong case in the same fashion, only the error message changes compared to 665.
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.
Ah right 👍