#47745 [Asn]: FILTER_VALIDATE_INT doesn't allow minimum integer
ID: 47745 User updated by: for-bugs at hnw dot jp Reported By: for-bugs at hnw dot jp Status: Assigned Bug Type: Filter related Operating System: * PHP Version: 5.2.9 Assigned To: dmitry New Comment: Result on 64bit environment: $ php -r 'var_dump(intval((string)~PHP_INT_MAX));' int(-9223372036854775808) $ php -r 'var_dump(filter_var((string)~PHP_INT_MAX, FILTER_VALIDATE_INT));' bool(false) There is same problem on 64bit environment, I think. Previous Comments: [2009-03-30 19:47:42] il...@php.net The multiplication is done by the standard ZEND macro, so if there is a limit issue it needs to be handled inside the Zend Engine. That said on my 64bit machine, I cannot reproduce the issue via - PHP_INT_MAX [2009-03-29 21:38:18] scott...@php.net Must have been sleep deprived when I looked at this last. [2009-03-29 16:47:47] paj...@php.net The only problem is the value we use for the max unsigned range. It should be changed to allow - 2^31, but I did not check the code more in details, but Ilia is on it so :) [2009-03-29 16:43:23] il...@php.net We don't eat a 0. When parsing #s we follow this logic: Let's say X is our temp var containing the 1st digit and the number to be parsed is 435. X = X * 10; X += 3; (X = 43) X = X * 10; X += 5; (X = 435) There is no 0 eating etc... [2009-03-26 22:44:17] scott...@php.net For some reason php_filter_parse_int multiplies the integer by ten then attempts to eat a 0? This is causing overflow and resulting in an error. I have no idea why its doing this though. ilia? The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/47745 -- Edit this bug report at http://bugs.php.net/?id=47745&edit=1
#47745 [Asn]: FILTER_VALIDATE_INT doesn't allow minimum integer
ID: 47745 Updated by: il...@php.net Reported By: for-bugs at hnw dot jp Status: Assigned Bug Type: Filter related Operating System: * PHP Version: 5.2.9 -Assigned To: iliaa +Assigned To: dmitry New Comment: The multiplication is done by the standard ZEND macro, so if there is a limit issue it needs to be handled inside the Zend Engine. That said on my 64bit machine, I cannot reproduce the issue via - PHP_INT_MAX Previous Comments: [2009-03-29 21:38:18] scott...@php.net Must have been sleep deprived when I looked at this last. [2009-03-29 16:47:47] paj...@php.net The only problem is the value we use for the max unsigned range. It should be changed to allow - 2^31, but I did not check the code more in details, but Ilia is on it so :) [2009-03-29 16:43:23] il...@php.net We don't eat a 0. When parsing #s we follow this logic: Let's say X is our temp var containing the 1st digit and the number to be parsed is 435. X = X * 10; X += 3; (X = 43) X = X * 10; X += 5; (X = 435) There is no 0 eating etc... [2009-03-26 22:44:17] scott...@php.net For some reason php_filter_parse_int multiplies the integer by ten then attempts to eat a 0? This is causing overflow and resulting in an error. I have no idea why its doing this though. ilia? [2009-03-21 23:34:01] for-bugs at hnw dot jp Description: Although -2147483648 is the minimum integer in 32bit environment, FILTER_VALIDATE_INT says -2147483648 is invalid as integer. Reproduce code: --- http://bugs.php.net/?id=47745&edit=1
#47745 [Asn]: FILTER_VALIDATE_INT doesn't allow minimum integer
ID: 47745 Updated by: scott...@php.net Reported By: for-bugs at hnw dot jp Status: Assigned Bug Type: Filter related Operating System: * PHP Version: 5.2.9 Assigned To: iliaa New Comment: Must have been sleep deprived when I looked at this last. Previous Comments: [2009-03-29 16:47:47] paj...@php.net The only problem is the value we use for the max unsigned range. It should be changed to allow - 2^31, but I did not check the code more in details, but Ilia is on it so :) [2009-03-29 16:43:23] il...@php.net We don't eat a 0. When parsing #s we follow this logic: Let's say X is our temp var containing the 1st digit and the number to be parsed is 435. X = X * 10; X += 3; (X = 43) X = X * 10; X += 5; (X = 435) There is no 0 eating etc... [2009-03-26 22:44:17] scott...@php.net For some reason php_filter_parse_int multiplies the integer by ten then attempts to eat a 0? This is causing overflow and resulting in an error. I have no idea why its doing this though. ilia? [2009-03-21 23:34:01] for-bugs at hnw dot jp Description: Although -2147483648 is the minimum integer in 32bit environment, FILTER_VALIDATE_INT says -2147483648 is invalid as integer. Reproduce code: --- http://bugs.php.net/?id=47745&edit=1
#47745 [Asn]: FILTER_VALIDATE_INT doesn't allow minimum integer
ID: 47745 Updated by: paj...@php.net Reported By: for-bugs at hnw dot jp Status: Assigned Bug Type: Filter related Operating System: * PHP Version: 5.2.9 Assigned To: iliaa New Comment: The only problem is the value we use for the max unsigned range. It should be changed to allow - 2^31, but I did not check the code more in details, but Ilia is on it so :) Previous Comments: [2009-03-29 16:43:23] il...@php.net We don't eat a 0. When parsing #s we follow this logic: Let's say X is our temp var containing the 1st digit and the number to be parsed is 435. X = X * 10; X += 3; (X = 43) X = X * 10; X += 5; (X = 435) There is no 0 eating etc... [2009-03-26 22:44:17] scott...@php.net For some reason php_filter_parse_int multiplies the integer by ten then attempts to eat a 0? This is causing overflow and resulting in an error. I have no idea why its doing this though. ilia? [2009-03-21 23:34:01] for-bugs at hnw dot jp Description: Although -2147483648 is the minimum integer in 32bit environment, FILTER_VALIDATE_INT says -2147483648 is invalid as integer. Reproduce code: --- http://bugs.php.net/?id=47745&edit=1
#47745 [Asn]: FILTER_VALIDATE_INT doesn't allow minimum integer
ID: 47745 Updated by: il...@php.net Reported By: for-bugs at hnw dot jp Status: Assigned Bug Type: Filter related Operating System: * PHP Version: 5.2.9 Assigned To: iliaa New Comment: We don't eat a 0. When parsing #s we follow this logic: Let's say X is our temp var containing the 1st digit and the number to be parsed is 435. X = X * 10; X += 3; (X = 43) X = X * 10; X += 5; (X = 435) There is no 0 eating etc... Previous Comments: [2009-03-26 22:44:17] scott...@php.net For some reason php_filter_parse_int multiplies the integer by ten then attempts to eat a 0? This is causing overflow and resulting in an error. I have no idea why its doing this though. ilia? [2009-03-21 23:34:01] for-bugs at hnw dot jp Description: Although -2147483648 is the minimum integer in 32bit environment, FILTER_VALIDATE_INT says -2147483648 is invalid as integer. Reproduce code: --- http://bugs.php.net/?id=47745&edit=1