From:             geissert at debian dot org
Operating system: 
PHP version:      5.3.1
PHP Bug Type:     Filter related
Bug description:  ext/filter/tests/046.phpt fails, does not detect int overflow

Description:
------------
The filter fails to detect an integer overflow and passes the
FILTER_VALIDATE_INT test. The problem is caused because
php_filter_parse_int uses a long to detect the overflow, which of course
doesn't have the same size of an integer.

This can be fixed by making ctx_value an integer in both
php_filter_parse_int and php_filter_int (and for correctness, not setting
Z_TYPE_P(value) to IS_LONG).


Reproduce code:
---------------
// the current test:
$s = sprintf("%d", PHP_INT_MAX);
var_dump(is_long(filter_var($s, FILTER_VALIDATE_INT)));

$s = sprintf("%.0f", PHP_INT_MAX+1);
var_dump(filter_var($s, FILTER_VALIDATE_INT));

$s = sprintf("%d", -PHP_INT_MAX);
var_dump(is_long(filter_var($s, FILTER_VALIDATE_INT)));

Expected result:
----------------
bool(true)
bool(false)
bool(true)


Actual result:
--------------
bool(true)
int(-2147483648)
bool(true)

-- 
Edit bug report at http://bugs.php.net/?id=51023&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=51023&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=51023&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=51023&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=51023&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=51023&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=51023&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=51023&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=51023&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=51023&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=51023&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=51023&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=51023&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=51023&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=51023&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=51023&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=51023&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=51023&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=51023&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=51023&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=51023&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=51023&r=mysqlcfg

Reply via email to