php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60049 Memcached does not handle invalid keys
Submitted: 2011-10-13 08:18 UTC Modified: 2021-06-09 11:27 UTC
Votes:9
Avg. Score:4.7 ± 0.7
Reproduced:8 of 8 (100.0%)
Same Version:2 (25.0%)
Same OS:2 (25.0%)
From: foehr at lotum dot de Assigned: cmb (profile)
Status: Closed Package: memcached (PECL)
PHP Version: 5.3.8 OS: Linux (Debian 5)
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 !
Your email address:
MUST BE VALID
Solve the problem:
48 - 22 = ?
Subscribe to this entry?

 
 [2011-10-13 08:18 UTC] foehr at lotum dot de
Description:
------------
Calling Memcached with invalid keys (too long, invalid characters) leads to 
strange behavior.
Calling get with an invalid key and after that getMulti with a valid key does not 
work (see below).


Versions:
memcached support => enabled
libmemcached version => 0.52

PECL:
memcached 1.0.2   stable


Test script:
---------------
<?php

class MemcachedTest extends \PHPUnit_Framework_TestCase
{
    public function testSet()
    {
        $mc = new Memcached();
        $mc->addServer('127.0.0.1', 11211);

        $mc->get(str_pad('', 300, 'x'));
        // it is "NOT FOUND"
        $this->assertEquals(Memcached::RES_BAD_KEY_PROVIDED, $mc->getResultCode());

        $mc->getMulti(array('foo'));
        // it is "SERVER HAS FAILED AND IS DISABLED UNTIL TIMED RETRY"
        $this->assertEquals(Memcached::RES_BAD_KEY_PROVIDED, $mc->getResultCode());
    }
}


Expected result:
----------------
The first $mc->get should lead to a result code "BAD KEY PROVIDED".
The second $mc->getMulti be "NOT FOUND" or "SUCCESS" depending on the cache 
content.

Actual result:
--------------
The first $mc->get sets the result code to "NOT FOUND".
The second $mc->getMulti sets the result code to "SERVER HAS FAILED AND IS 
DISABLED UNTIL TIMED RETRY".

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-06-09 11:27 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2021-06-09 11:27 UTC] cmb@php.net
The memcached bug tracker is now on Github[1].  If this is still
an issue with the current memcached version, please report there.

[1] <https://github.com/php-memcached-dev/php-memcached/issues>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 18:01:30 2024 UTC