#27428 [NEW]: serialize brakes output for unserialize, returning garbage
| From: | black at scene-si dot org | Date: | Sat, 28 Feb 2004 01:31:56 +0000 |
| Subject: | #27428 [NEW]: serialize brakes output for unserialize, returning garbage | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-55673@lists.php.net to get a copy of this message | ||
From: black at scene-si dot org
Operating system: debian unstable
PHP version: Irrelevant
PHP Bug Type: Strings related
Bug description: serialize brakes output for unserialize, returning garbage
Description:
------------
The following has been tested on:
php-4.3.2
php-4.3.4
php-4.3.5rc2
php-4.3.5rc3
php4-STABLE-200310032330
php4-STABLE-200402101030
php4-STABLE-200402272030
with various compile options turned on/off (oracle support &
turckmmcache), always giving same result
basically with every version of this some or most serialize() calls result
in an incorrectlly constructed serialized string... given i only input
plaintext, the serialized string must have a length of 6+strlen(original),
albeit:
["cache_data"]=> string(9277) "s:9309:"... (oops!)
["cache_data"]=> string(24259) "s:24248:"... (correct.)
["cache_data"]=> string(23850) "s:23881:"... (oops!)
["cache_data"]=> string(224081) "s:224069:"... (correct.)
["cache_data"]=> string(21055) "s:21107:"... (WTF!)
["cache_data"]=> string(19590) "s:19663:"... (wrong)
...
http://scene-si.org/test.tgz - 800kb, contains 15Mb
output of the
reproduce code.
http://193.77.198.80/phpinfo.php for phpinfo()
Linux dahim 2.4.23-1-686 #1 Sun Nov 30 20:51:10 EST 2003 i686 GNU/Linux
(thats the server this runs on).
the funny part is, that this code (the same code to generate the entries
in condor_dbcache) works also on other servers, also debian, iis,
apache-win, redhat, mandrake, openbsd, freebsd.. it only fucked here..
after the serialize is done, the ONLY command it goes trough is
mysql_escape_string, so there is no character or other conversions which
could explain the wrong length in serialized() output
Reproduce code:
---------------
<?php
mysql_pconnect("localhost","root","");
mysql_select_db("condor");
$query = mysql_query("select * from condor_dbcache");
while ($row = mysql_fetch_assoc($query)) {
var_dump($row);
var_dump(unserialize($row['cache_data']));
}
// unserialize throws out crap after serialized data end
Expected result:
----------------
I dont want the "; and crap after it displayed.. but more accurately.. i
want serialize to behave propperly here.
since i never had this problem, i pressume its a system dependant problem,
i guess you'll want this:
Reading specs from /usr/lib/gcc-lib/i486-linux/3.3.3/specs
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared
--with-system-zlib --enable-nls --without-included-gettext
--enable-__cxa_atexit --enable-clocale=gnu --enable-debug
--enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i486-linux
Thread model: posix
gcc version 3.3.3 (Debian)
if you need some other application version or lib version, comment - or
atleast tell on what libs this depends.
Actual result:
--------------
Content starts with ei: 's:9309:"<table wid' and ends with
'<br><br>";'
... but the content length is 9277..
the content was input with serialize in the following way:
$content = serialize($content);
mysql_query("update condor_dbcache set cache_timestamp='".time()."',
cache_data='".mysql_escape_string($content)."' where
cache_filename='".mysql_escape_string($filename)."'");
filename beeing the correspondant key to this dbcache table.
--
Edit bug report at http://bugs.php.net/?id=27428&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27428&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27428&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=27428&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=27428&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=27428&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=27428&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=27428&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=27428&r=support
Expected behavior: http://bugs.php.net/fix.php?id=27428&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=27428&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=27428&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=27428&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27428&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=27428&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=27428&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=27428&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27428&r=float