ID: 50970
Comment by: zhangsilly at gmail dot com
Reported By: zhangsilly at gmail dot com
Status: Open
Bug Type: Scripting Engine problem
Operating System: Windows XP
PHP Version: 5.2.12
New Comment:
this is cause by strtol, used in the ZEND_API convert_to_long_base(zval
*op, int base), which is defined in stdlib.h.
strtol will always return LONG_MAX if the string stands for a
number
which is larger than LONG_MAX.
I'am afraid no matter zend_parse_parameters and convert_to_long,
the
should have the same behavior.
This whill cause a situation that when i pass a string which is
readed from file or socket to long2ip, long2ip($str) is right but
long2ip((int)$str) will be failed.
Previous Comments:
------------------------------------------------------------------------
[2010-02-09 01:29:31] zhangsilly at gmail dot com
Description:
------------
use (int) or intval() to convert a string into integer in userland, if
bigger than 2147483647, this will result a truncate, the value will
always be 2147483647.
but use zend_parse_parameters to parse the string as a long
arguement, is do give the correct value in nagtive format
Reproduce code:
---------------
/**
* assert failure
* (int)3740925952 result is -554041344
* (int)'3740925952' result is 2147483647
*/
assert((int)3740925952 == (int)'3740925952');
Expected result:
----------------
assert should be succeed
Actual result:
--------------
assert failure
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50970&edit=1