php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3008 implode() garbages when string contains NUL
Submitted: 1999-12-19 18:39 UTC Modified: 2002-09-30 16:53 UTC
From: old dot wolf at nsionline dot com Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0.12 OS: RedHat Linux 6.1 i486 Apache 1.3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: old dot wolf at nsionline dot com
New email:
PHP Version: OS:

 

 [1999-12-19 18:39 UTC] old dot wolf at nsionline dot 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-09-30 16:53 UTC] hholzgra@php.net
works fine in 4.2.3
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 11:01:31 2024 UTC