php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39785 implode() causes PHP CGI to fail if given a NULL value
Submitted: 2006-12-10 09:38 UTC Modified: 2006-12-18 01:00 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: me at nbishop dot name Assigned:
Status: No Feedback Package: Arrays related
PHP Version: 5.2.0 OS: Fedora Core 4
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: me at nbishop dot name
New email:
PHP Version: OS:

 

 [2006-12-10 09:38 UTC] me at nbishop dot name
Description:
------------
This was some code I had been using since migrating to PHP5 since about 5.1.2 I believe at least, has worked since then until the server got upgraded to PHP 5.2.0

In short, I have a database call that gets made before the function, the database return can be NULL if no one has added anything into it (its a banned IP result, if no IPs are banned, result is NULL).

Basically what happens is if I do implode("," array($data['banned']));, in PHP 5.2 now it causes what seems to be the PHP CGI to fail (My server gives me a '400 Internal Server Error' message).

Sadly I don't have access to apache logs and such, so I can't give you much more beyond that.

PHP Configure Command:
../configure --program-suffix=5 --with-pear=/usr/local/lib/php5 --with-config-file-path=/usr/local/lib/php5 --with-libxml-dir=/usr/local/php5 --without-sqlite --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --with-xsl=/usr/local/php5 --enable-mbstring=all --with-curl=/usr/local/php5 --with-mcrypt=/usr/local/php5 --with-gd --with-pdo-mysql=/usr/local/mysql --with-freetype-dir --with-libxml-dir=/usr/local/php5 --with-mysql=/usr/local/mysql --with-zlib --enable-debug=no --enable-safe-mode=no --enable-discard-path=no --with-png-dir=/usr/lib --enable-track-vars --with-db --with-gdbm --enable-force-cgi-redirect --with-ttf=/usr/ --enable-ftp --enable-dbase --enable-memory-limit --enable-calendar --enable-wddx --with-jpeg-dir=/usr/src/php5/jpeg-6b --enable-bcmath --enable-gd-imgstrttf --enable-shmop --enable-mhash --with-mhash=/usr/src/php5/mhash-0.8.9/ --with-openssl --enable-xslt --with-xslt-sablot --with-dom --with-dom-xslt --with-dom-exslt --with-imap --with-iconv=/usr/local --with-bz2 --with-gettext --enable-exif --with-idn

Reproduce code:
---------------
$ban_array = implode(",", array($data['Banned']));
if (strstr($ban_array, $_SERVER['REMOTE_ADDR'])) {
	die("Banned");
}

Expected result:
----------------
That used to (if an IP matched in the banned IP's array from the database) pop up the 'Banned' error message, else if the database value for 'Banned' came back NULL, it would still continue to process with no errors.

I managed to work around this now in PHP 5.2 however by replacing the $ban_array line and adding another line before it, like such:
$banned = array(ltrim($data['Banned']));
$ban_array = implode(",", $banned);

Actual result:
--------------
Function ends up causing the server to kick out a 400 Internal Server Error, no script process, nothing, so error reporting variables didn't do nothing to show anything, cause it seems to cause the PHP CGI itself to fail some how.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-10 11:06 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [2006-12-18 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2008-07-09 11:48 UTC] kpobococ at gmail dot com
Also experienced this bug on PHP compiled as a module (with Apache 2.0). PHP version at the time was: 5.2.0-8+etch10.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 23:01:30 2024 UTC