php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #7621 NULL-bytes cause fundamental problems in string processing
Submitted: 2000-11-03 09:28 UTC Modified: 2000-11-27 14:05 UTC
From: vburwitz at mails-media dot de Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.3pl1 OS: GNU/Linux 2.2.13 (SuSE 6.3)
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: vburwitz at mails-media dot de
New email:
PHP Version: OS:

 

 [2000-11-03 09:28 UTC] vburwitz at mails-media dot de
Fundamental String Append Problem!!!

If NULL-bytes are in a string then appending the string won't work.

e.g. (NULL-byte written as "0" here)

$a ="abc0def";
$b ="1230456";

$a .=$b;

echo $a;
=> "abc"

echo strlen($a);
=> "3"

Well I don't have to mention that the problem is most probably
related to NULL-termination of strings in C/C++.

The above creates a lot of HUGE PROBLEMS and was working
with PHP3, since I am depending on NULL-safe string processing.

Could someone give me a fast reply if something more is known?

Thanks

V. Burwitz

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-11-03 13:31 UTC] waldschrott@php.net
hm, works for me (4.0.4dev win32)... strlen() is ok. output
is ok.
 [2000-11-03 19:19 UTC] waldschrott@php.net
your example (duped out) with chr(0) again works for me, I
tested now on win32 (4.0.4dev) AND linux(4.0.3dev), both are ok.
perhaps anyone else can try to verify
 [2000-11-05 06:28 UTC] stas@php.net
PHP 3 problem?
 [2000-11-15 17:28 UTC] waldschrott@php.net
user replied that problem is partly solved, anyway there's one NS4.x issue remaining

try this...
<?php
echo "abc\0XXX";
echo 'XXY'.str_repeat('as',60);
?>
NS4.x (mozilla,IE etc. won't) simply does not recognize a bunch of characters, it's apparently a Netscape bug and I'm sure we can't do anything here to improve the situation

any ideas anyone?
 [2000-11-27 06:36 UTC] waldschrott@php.net
Thought about it again, if NS4 cannot come along with \0 why
not strip them out then if the browser appears to be a NS4?
 [2000-11-27 14:05 UTC] waldschrott@php.net
thought about it twice, the above is no good idea, to many
checks needed, is output of type text/html and further, it
should be left to the user to cure browser lacks
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Jul 08 08:00:01 2026 UTC