From: dragos at codersnest dot com
Operating system: fedora 6
PHP version: 5.2.6
PHP Bug Type: Unknown/Other Function
Bug description: ctype_digit not validating int values
Description:
------------
When passing an integer to ctype_digit, it will fail validating it. I
tested several times, looks like this behaviour is consistent, I also tried
using ctype_digit(65) which will also return "false".
The PHP version is actually 5.1.6, running on Fedora 6 x86_64 with Apache
2.2.6 , all installed from the Fedora Repository.
Same behaviour successfully reproduced with PHP 5.2.5 + Apache 2.0.54 on
Suse9 x86_64.
Possibly somewhere when the parameter passed is cast to a string, the
value is somehow corrupted.
Reproduce code:
---------------
function getm($width, $height) {
$errors = array();
if (!ctype_digit($width) || (int)$width <=0 ) {
$errors[] = 'Width must be a positive integer value, ' .
gettype($width)
. ' passed';
}
if (!ctype_digit($height) || (int)$height<=0 ) {
$errors[] = 'Height must be a positive integer value, ' .
gettype($height) . ' passed';
}
return $errors;
}
$a = getm(48, 65);
var_dump($a);
Expected result:
----------------
array (0) {}
Actual result:
--------------
array(1) {
[0]=>
string(55) "Height must be a positive integer value, integer passed"
}
--
Edit bug report at http://bugs.php.net/?id=45710&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=45710&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=45710&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=45710&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=45710&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=45710&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=45710&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=45710&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=45710&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=45710&r=support
Expected behavior: http://bugs.php.net/fix.php?id=45710&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=45710&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=45710&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=45710&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45710&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=45710&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=45710&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=45710&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=45710&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=45710&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=45710&r=mysqlcfg