php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59681 incr/decr work only with 32-bit delta values
Submitted: 2011-03-23 09:08 UTC Modified: 2017-10-24 06:59 UTC
From: marcin dot babij+php at nasza-klasa dot pl Assigned:
Status: Open Package: memcache (PECL)
PHP Version: 5.3.0 OS: debian
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: marcin dot babij+php at nasza-klasa dot pl
New email:
PHP Version: OS:

 

 [2011-03-23 09:08 UTC] marcin dot babij+php at nasza-klasa dot pl
Description:
------------
Memcache client isn't able to increment or decrement keys by values larger that or equal to 2^31, because it cast delta argument to 32-bit int.

Reproduce code:
---------------
Increment any key by 2500000000.

Patch:
memcache.c:
243c243
< static int mmc_incr_decr(mmc_t *, int, char *, int, int, long * TSRMLS_DC);
---
> static int mmc_incr_decr(mmc_t *, int, char *, int, long, long * TSRMLS_DC);
1743c1743
< static int mmc_incr_decr(mmc_t *mmc, int cmd, char *key, int key_len, int value, long *number TSRMLS_DC) /* {{{ */
---
> static int mmc_incr_decr(mmc_t *mmc, int cmd, char *key, int key_len, long value, long *number TSRMLS_DC) /* {{{ */
1749c1749
< command_len = spprintf(&command, 0, "incr %s %d", key, value);
---
> command_len = spprintf(&command, 0, "incr %s %ld", key, value);
1752c1752
< command_len = spprintf(&command, 0, "decr %s %d", key, value);
---
> command_len = spprintf(&command, 0, "decr %s %ld", key, value);

Still, it will not fix it on 32-bit machines, but one could try using 'long long' and '%lld', but more changes might be required in other functions, as they seem to user 'long' values too.

Actual result:
--------------
CLIENT_ERROR invalid numeric delta argument

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-10-24 06:59 UTC] kalle@php.net
-Status: Assigned +Status: Open -Assigned To: hradtke +Assigned To:
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Jun 17 15:01:46 2019 UTC