#3008 [Opn->Csd]: implode() garbages when string contains NUL

From: Date: Mon, 30 Sep 2002 21:53:57 +0000
Subject: #3008 [Opn->Csd]: implode() garbages when string contains NUL
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-20798@lists.php.net to get a copy of this message
ID: 3008 Updated by: hholzgra@php.net Reported By: old.wolf@nsionline.com -Status: Open +Status: Closed Bug Type: Misbehaving function Operating System: RedHat Linux 6.1 i486 Apache 1.3 PHP Version: 3.0.12 New Comment: works fine in 4.2.3 Previous Comments: ------------------------------------------------------------------------ [1999-12-19 18:39:31] old.wolf@nsionline.com When implode() is called with an array which contains a string which contains NUL ie. chr(0), the output of implode() contains garbage, from the point where the NUL ought to have occurred, onwards. The following code demonstrates this. <?php $buggy_string = "this bit is ok" . chr(0) . "garbagegarbagegarbage"; $ok_array = array("hello", $buggy_string); $msg_fields = implode("|", $ok_array); echo "buggy_string is <B>$buggy_string</B>.<BR>\n"; echo "members of array are:<B> "; while (list($z, $member) = each($ok_array)) echo $member . ", "; echo "</B><BR>\n"; echo "imploded array is <B>$msg_fields</B>.<BR>\n"; ?> This program's output differs with each execution, an example is: buggy_string is this bit is okgarbagegarbagegarbage. members of array are: hello, this bit is okgarbagegarbagegarbage, imploded array is hello|this bit is ok>+SELFhello|this. My configure-string was: ./configure --with-apache=/usr/local/src/apache_1.3.9 --enable-track-vars --with-mcrypt=/usr/local/libmcrypt --with-mhash=/usr/local/mhash --with-mysql=/usr/local/mysql ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=3008&edit=1

« previous php.bugs (#20798) next »