PHP 4.0 Bug #4255: left shift op (<<) on large 32 bit integer causes core dump
| From: | ctsmhn at cts dot com | Date: | Wed, 26 Apr 2000 22:12:34 +0000 |
| Subject: | PHP 4.0 Bug #4255: left shift op (<<) on large 32 bit integer causes core dump | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-18224@lists.php.net to get a copy of this message | ||
From: ctsmhn@cts.com
Operating system: FreeBSD 4.0
PHP version: 4.0 Release Candidate 1
PHP Bug Type: Reproduceable crash
Bug description: left shift op (<<) on large 32 bit integer causes core dump
To reproduce the crash:
$localnets = array ( "192.91.199.128/25",
"192.91.55.64/26" );
foreach ($localnets as $net) {
list ($addr, $bits) = explode("/", $net);
// convert the dotted quad network address into a 32 bit integer
list ($a, $b, $c, $d) = explode(".", $addr);
$numaddr = ($a << 24) + ($b << 16) + ($c << 8) + $d;
// convert the dotted quad remote address into a 32 bit integer
list ($a, $b, $c, $d) = explode(".", $REMOTE_ADDR);
$rnumaddr = ($a << 24) + ($b << 16) + ($c << 8) + $d;
$mask = bits2mask($bits);
echo ((($rnumaddr & $mask) == $numaddr) ? "Local" : "Remote") .
"\n";
}
function bits2mask ($bits) {
$mask = 0xFFFFFFFF;
$mask <<= $bits; // This should put 32 - $bits zeros at the end of
// $mask, thus giving me the proper subnet mask.
// Instead, since the assignment of $mask to
// 0xFFFFFFFF yields 0, the algorithm is hosed.
// See bug report 4254 for more on this problem.
// To work around this, I can do:
$mask = 0x7FFFFFFF + 0x7FFFFFFF + 1; // achieves 0xFFFFFFFF
$mask <<= $bits; // <--- THIS CAUSES THE CORE DUMP
return $mask;
}
./configure --with-apache=../apache_1.3.12i --enable-sysvsem --enable-sysvshm --enable-wddx
--enable-xml --with-pgsql=/usr/local/postgres --enable-track-vars --enable-trans-sid
--enable-session