Bug #60395 [NEW]: Null byte in source causes file to be ignored, no error or warning reported
From:
Operating system: any
PHP version: Irrelevant
Package: Unknown/Other Function
Bug Type: Bug
Bug description:Null byte in source causes file to be ignored, no error or warning reported
Description:
------------
NULL bytes in the source code seem to confuse PHP. See test script below.
The
code in the file is not executed, and no error or warning is shown.
The result is the same if you run it from the command line or from a web
server
(ruling out a web server problem).
This bug has been discovered on MacOS X (10.6.8) with a default, unpatched
PHP
5.3.6; but it has been reproduced (so far) as well on Debian 2.6.26-2 with
the
most recent version of PHP.
It does not matter where the null byte(s) is/are placed. They can even be
inside
a comment!
I discovered this bug by accident as I had inadvertently copied a NULL-byte
into
a comment inside a file that I was require()'ing from elsewhere. The
require()'d
code was not run, but, even with error_reporting(-1), no warning or error
message was displayed. I couldn't figure out what was wrong until I looked
at
the file with a text editor that can make non-printing characters visible.
Removing the NULL byte fixed the problem.
Test script:
---------------
This is a 1-line PHP script that contains a single NULL byte:
http://dl.dropbox.com/u/257587/test.php
Just showing printable chars, the contents of this file is:
<?php echo "Hi"; ?>
The NULL byte is located after the closing semicolon. (However, the exact
location is irrelevant in order to reproduce the bug.)
Expected result:
----------------
The string 'Hi' should be output.
Actual result:
--------------
Instead, PHP outputs a number of non-printing characters (usually shown as
question marks). Depending on the position and number of NULL bytes in the
source
code, the output may also be nothing at all.
--
Edit bug report at https://bugs.php.net/bug.php?id=60395&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=60395&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=60395&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=60395&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=60395&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60395&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=60395&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=60395&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=60395&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=60395&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=60395&r=support
Expected behavior: https://bugs.php.net/fix.php?id=60395&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=60395&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=60395&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=60395&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=60395&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=60395&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=60395&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=60395&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=60395&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=60395&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=60395&r=mysqlcfg
Thread (6 messages)
- nh at ngin dot de
- laruence@php.netBug #60395 [Opn]: Null byte in source causes file to be ignored, no error or warning reported
- laruence@php.netBug #60395 [Com]: Null byte in source causes file to be ignored, no error or warning reported
- nh at ngin dot deBug #60395 [Opn]: Null byte in source causes file to be ignored, no error or warning reported
- nh at ngin dot deBug #60395 [Opn]: Null byte in source causes file to be ignored, no error or warning reported
- laruence@php.netBug #60395 [Opn]: Null byte in source causes file to be ignored, no error or warning reported