#44072 [NEW]: substr don't work correctly with binary stings

From: Date: Thu, 07 Feb 2008 18:31:06 +0000
Subject: #44072 [NEW]: substr don't work correctly with binary stings
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-122078@lists.php.net to get a copy of this message
From:             sergey89 at gmail dot com
Operating system: FreeBSD 6.3
PHP version:      5.2.5
PHP Bug Type:     Strings related
Bug description:  substr don't work correctly with binary stings

Description:
------------
substr don't work correctly with binary strings on FreeBSD 6.3, PHP 5.2.5.
I have some binary file. When i tried to cut part of data i get incorrect
result.

-----
mbstring.function_overload 0

Reproduce code:
---------------
<?php
$data = file_get_contents('data');
print md5($data) . ' | ';
print md5(substr($data, 0, -88));
?>

Expected result:
----------------
45e26dc33aad8e93f3f45c8d5100feb0 | 03d900cc2ba7276fb3bb3f1939303e3b

Actual result:
--------------
45e26dc33aad8e93f3f45c8d5100feb0 | d1cea9d93cb48b2d897595f5e96ba352

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


Thread (10 messages)

« previous php.bugs (#122078) next »