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: 2020-03-22 04:22 UTC
From: marcin dot babij+php at nasza-klasa dot pl Assigned: cmb (profile)
Status: No Feedback Package: memcache (PECL)
PHP Version: 5.3.0 OS: debian
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: 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:
 [2020-03-13 16:46 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2020-03-13 16:46 UTC] cmb@php.net
It seems that current versions use zend_long, so this should be
fixed.
 [2020-03-22 04:22 UTC] pecl-dev at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 08:01:30 2024 UTC