From: sefer at hotmail dot com
Operating system: Linux redhat 9
PHP version: 4.3.10
PHP Bug Type: Compile Warning
Bug description: Incorrect C code in unpack.c causes misbehavior and warnings
Description:
------------
In the recent PHP release 4.3.10 there had been added a bug to the unpack
(PHP_FUNCTION(unpack)) function in unpack.c
The code that manifests the problem is this:
$h = unpack('H*hex', $data);
The result would be:
Warning: unpack(): Type H: outside of string in /my_file.php on line 20
The reason is a change in the function which using the current compiler
(Red Hat Linux 3.2.3-42) generates incorrect behavior when "break" is
placed within a curly braces block (within a "switch" statement) which
causes break to leave the current scope but then continue falling down
through the "switch" elements.
For example this code:
case 'C': {
int issigned = (type == 'c') ? (input[inputpos] & 0x80) : 0;
long v = php_unpack(&input[inputpos], 1, issigned, byte_map);
add_assoc_long(return_value, n, v);
break;
}
case 's':
The correct setup needs to move the "break" outside the {...} scope, which
would then fix the problem.
This behavior is apparent in several places throughout that function and
needs to be corrected in all of them.
Thanks,
Sefer.
--
Edit bug report at http://bugs.php.net/?id=31247&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31247&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=31247&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=31247&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=31247&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=31247&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=31247&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=31247&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=31247&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=31247&r=support
Expected behavior: http://bugs.php.net/fix.php?id=31247&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=31247&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=31247&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=31247&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31247&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=31247&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=31247&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=31247&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=31247&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=31247&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=31247&r=mysqlcfg