php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14580 Incorrect behavior with key containing NULL byte
Submitted: 2001-12-18 10:32 UTC Modified: 2002-07-08 03:02 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: jlpriou at coleebris dot com Assigned:
Status: Closed Package: Arrays related
PHP Version: 4.3.0-dev OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jlpriou at coleebris dot com
New email:
PHP Version: OS:

 

 [2001-12-18 10:32 UTC] jlpriou at coleebris dot com
We are trying using array wich contain as key a binary value.
We have no problem when storing this key and value in the array,
but when we want to get the key, the key is truncated  !

Tested with Php 4.0.6 and 4.1.0

<?
$key = "string\0withnull";
echo "strlen(" . urlencode($key) . ") = " . strlen($key) . "<br>";

$a = array($key => "val");

echo $a[$key] . "<br>";     // Result is correct

reset($a) ;
echo (key($a) == $key) ? "equal" : "not equal" ;    // part of the key is lost
echo "(" . urlencode(key($a)) ." == ". urlencode($key) .")" ;
?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-03 21:03 UTC] eru@php.net
Seems to fail only with \0 every other escape-sequence works fine.

 [2002-07-08 03:02 UTC] derick@php.net
This bug has been fixed in CVS. You can grab a snapshot of the CVS version at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better.

Derick
 [2003-02-28 14:37 UTC] yakov at schmirnov dot net
the problem was \0 is the end of string marker in c.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 07:01:30 2024 UTC