php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59046 Problems if "\0" within the key
Submitted: 2010-01-26 04:44 UTC Modified: 2010-03-05 03:18 UTC
From: marc dot bennewitz at giata dot de Assigned:
Status: Wont fix Package: APC (PECL)
PHP Version: 5_3.1RC2 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
5 + 12 = ?
Subscribe to this entry?

 
 [2010-01-26 04:44 UTC] marc dot bennewitz at giata dot de
Description:
------------
Sometimes if the key has the "\0"-character within caching storing or reading of this item fails.

Reproduce code:
---------------
apc_store("\0", "test1");
var_dump(apc_exists("\0"));
var_dump(apc_fetch("\0"));

apc_store("-\0-", "test2");
var_dump(apc_exists("-\0-"));
var_dump(apc_fetch("-\0-"));

apc_store("-\1-", "test3");
var_dump(apc_exists("-\1-"));
var_dump(apc_fetch("-\1-"));

Expected result:
----------------
bool(true)
string(5) "test1"
bool(true)
string(5) "test2"
bool(true)
string(5) "test3"

Actual result:
--------------
bool(true)
string(5) "test1"
NULL
bool(false)
bool(true)
string(5) "test3"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-05 02:19 UTC] kalle@php.net
This is because those functions are not binary safe
 [2010-03-05 02:24 UTC] rasmus@php.net
The values are binary safe, but the keys aren't.  I don't see 
any real reason to change that.  It simplifies things to have 
null-terminated keys.
 [2010-03-05 03:18 UTC] marc dot bennewitz at giata dot de
ok, but than it should report a warning/notice and return false instead of null on storing.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 01:01:28 2024 UTC