PHP 4.0 Bug #8921: Require() function : filename string not terminated correctly internally
| From: | mahony at cwa dot co dot nz | Date: | Fri, 26 Jan 2001 00:18:31 +0000 |
| Subject: | PHP 4.0 Bug #8921: Require() function : filename string not terminated correctly internally | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-45024@lists.php.net to get a copy of this message | ||
From: mahony@cwa.co.nz
Operating system: Linux Debian Potato 2.2
PHP version: 4.0.4pl1
PHP Bug Type: Unknown/Other Function
Bug description: Require() function : filename string not terminated correctly internally
Hi,
I've found what appears to be a reproducable bug with random effects.
When I pass a seemingly perfect filename string to the Require() function it comes back (2 times out
of 3) with extra characters at the end, causing the require function to fail to find the file. The
characters are illustrated below, and many seem to be non-alphabetic. It looks like a C string
buffer overflow problem (ie: the length of the string has been enlarged by a random amount between
about 2 and 5 characters, and it's picking up additional characters directly out of memory).
This is the code that is executing :
if("" == $inc_filename) {
print("You have to enter a filename first !");
}
else // NON-Blank include filename
{
print("Filename = ".$inc_filename); // <<<<< Note : here the filename
displays fine
require( $inc_filename ); // <<<<< Note : here it is corrupted
}
These are the output lines I got (note the crap at the end of the filename in the error message) :
Filename = inc/britz/britzspg.inc
Fatal error: Failed opening required 'inc/britz/britzspg.incÿ¿ñ'
(include_path='.:/usr/local/lib/php') in
/home/ekiwi/public_html/layout.php on line 199
Filename = inc/britz/britzspg.inc
Fatal error: Failed opening required 'inc/britz/britzspg.inc)y'
(include_path='.:/usr/local/lib/php') in
/home/ekiwi/public_html/layout.php
on line 199
THEN IT WAS OK TWICE, followed by
Filename = inc/britz/britzspg.inc
Fatal error: Failed opening required 'inc/britz/britzspg.inc'A'
(include_path='.:/usr/local/lib/php') in
/home/ekiwi/public_html/layout.php
on line 199
Filename = inc/britz/britzspg.inc
Fatal error: Failed opening required 'inc/britz/britzspg.inc)±'
(include_path='.:/usr/local/lib/php') in
/home/ekiwi/public_html/layout.php
on line 199
To see this in action see :
http://chips.cwa.co.nz:8080/display.php?FEATURE_ID=13
Be aware that it works perfectly about a third of the time, so keep pressing the refresh button on
your browser until it throws the error.
We're running Linux kernal 2.2.18
Our PHP config details are available at :
http://chips.cwa.co.nz/~ian/php.status.php
Hope this helps,
Simon Mahony,
Technical Director,
CWA New Media,
New Zealand.
--
Edit Bug report at: http://bugs.php.net/?id=8921&edit=1