php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59080 cas flag not restored in php_memc_get_impl
Submitted: 2010-02-21 02:32 UTC Modified: 2010-05-03 15:50 UTC
From: sskaje at gmail dot com Assigned:
Status: Closed Package: memcached (PECL)
PHP Version: Irrelevant OS: CentOS(Irrelevant)
Private report: No CVE-ID: None
 [2010-02-21 02:32 UTC] sskaje at gmail dot com
Description:
------------
Line 395 in php_memcached.c:

if (php_memc_handle_error(status TSRMLS_CC) < 0) {
	memcached_result_free(&result);
	RETURN_FALSE;
}

Suppose orig_cas_flag was 0 and then set true. 
If we are using a old version of protocol which doesn't 
support 'gets', a protocol error will be returned (result 
code 8) when we specified the $cas_token in 
Memcached::get(). 
The next time we use Memcached::get() without $cas_token 
supplied, polluted flag 'support_cas' was not restored to 0 
and then another protocol error will be returned.

I've written a blog here(in Chinese): 
http://blog.sskaje.name/2010/02/phpmemcached-memcacheq.html

Google translator might work fine with it.

Solution is at the end of that blog.

Reproduce code:
---------------
Blog url: http://blog.sskaje.name/2010/02/phpmemcached-memcacheq.html

Expected result:
----------------
[root@localhost 3.53]: 
/data1/www/htdocs/i.sina.com.cn/source/apps/daemon/cron
0> php testMemcachedGet.php 
int(140)
int(0)
int(141)
int(0)

mcdgettest: 
bool(false)
int(8)
bool(false)
int(8)

mcdgettest1: 
bool(142)
int(0)

mcdgettest2: 
bool(false)
int(8)

mcdgettest3: 
bool(143)
int(0)
END

int(144)
int(0)
int(145)
int(0)

mcdgettest3: 
int(146)
int(0)

mcdgettest2: 
bool(false)
int(8)

mcdgettest1: 
bool(147)
int(0)

mcdgettest: 
bool(false)
int(8)
bool(false)
int(8)
END

int(148)
int(0)
int(149)
int(0)

mcdgettest3: 
int(150)
int(0)

mcdgettest1: 
int(151)
int(0)

mcdgettest2: 
bool(false)
int(8)

mcdgettest: 
bool(false)
int(8)
bool(false)
int(8)
END

Actual result:
--------------
[root@localhost 3.53]: 
/data1/www/htdocs/i.sina.com.cn/source/apps/daemon/cron
0> php testMemcachedGet.php 
int(140)
int(0)
int(141)
int(0)

mcdgettest: 
bool(false)
int(8)
bool(false)
int(8)

mcdgettest1: 
bool(false)
int(8)

mcdgettest2: 
bool(false)
int(8)

mcdgettest3: 
bool(false)
int(8)
END

int(142)
int(0)
int(143)
int(0)

mcdgettest3: 
int(144)
int(0)

mcdgettest2: 
bool(false)
int(8)

mcdgettest1: 
bool(false)
int(8)

mcdgettest: 
bool(false)
int(8)
bool(false)
int(8)
END

int(145)
int(0)
int(146)
int(0)

mcdgettest3: 
int(147)
int(0)

mcdgettest1: 
int(148)
int(0)

mcdgettest2: 
bool(false)
int(8)

mcdgettest: 
bool(false)
int(8)
bool(false)
int(8)
END

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-03 15:50 UTC] andrei@php.net
Thank you for the report. It's been fixed on master branch, and will be available in 2.0 release.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 13 21:01:27 2024 UTC