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: -
Votes:8
Avg. Score:4.9 ± 0.3
Reproduced:7 of 7 (100.0%)
Same Version:1 (14.3%)
Same OS:2 (28.6%)
From: foehr at lotum dot de Assigned:
Status: Open Package: memcached (PECL)
PHP Version: 5.3.8 OS: Linux (Debian 5)
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: foehr at lotum dot de
New email:
PHP Version: OS:

 

 [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

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Dec 08 15:01:25 2019 UTC