Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfaa4bc2

Browse files
Don't cast a uint64_t to a long.
We recently updated PhpRedis to handle `SCAN` cursors > 2^63 as strings(as internally PHP integers are longs).However, the `redis_build_scan_cmd` took the cursor as a long, whichwould overflow if the value was > `2^63`.This commit simply changes the function to take a `uint64_t` and callour specific `redis_append_sstr_u64` so we send the cursor to Rediscorrectly.Fixes#2454.
1 parent3f8dba6 commitfaa4bc2

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

‎redis.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2694,9 +2694,9 @@ PHP_METHOD(Redis, copy) {
26942694
/* }}} */
26952695

26962696
/* Helper to format any combination of SCAN arguments */
2697-
PHP_REDIS_APIint
2697+
staticint
26982698
redis_build_scan_cmd(char**cmd,REDIS_SCAN_TYPEtype,char*key,intkey_len,
2699-
longiter,char*pattern,intpattern_len,intcount,
2699+
uint64_tcursor,char*pattern,intpattern_len,intcount,
27002700
zend_string*match_type)
27012701
{
27022702
smart_stringcmdstr= {0};
@@ -2727,7 +2727,7 @@ redis_build_scan_cmd(char **cmd, REDIS_SCAN_TYPE type, char *key, int key_len,
27272727
/* Start the command */
27282728
redis_cmd_init_sstr(&cmdstr,argc,keyword,strlen(keyword));
27292729
if (key_len)redis_cmd_append_sstr(&cmdstr,key,key_len);
2730-
redis_cmd_append_sstr_long(&cmdstr,iter);
2730+
redis_cmd_append_sstr_u64(&cmdstr,cursor);
27312731

27322732
/* Append COUNT if we've got it */
27332733
if(count) {
@@ -2751,7 +2751,7 @@ redis_build_scan_cmd(char **cmd, REDIS_SCAN_TYPE type, char *key, int key_len,
27512751
returncmdstr.len;
27522752
}
27532753

2754-
/* {{{ proto redis::scan(&$iterator, [pattern, [count, [type]]]) */
2754+
/* {{{ proto redis::scan(&$cursor, [pattern, [count, [type]]]) */
27552755
PHP_REDIS_APIvoid
27562756
generic_scan_cmd(INTERNAL_FUNCTION_PARAMETERS,REDIS_SCAN_TYPEtype) {
27572757
zval*object,*z_cursor;
@@ -2818,7 +2818,7 @@ generic_scan_cmd(INTERNAL_FUNCTION_PARAMETERS, REDIS_SCAN_TYPE type) {
28182818
* pattern. phpredis can be set up to abstract this from the user, by
28192819
* setting OPT_SCAN to REDIS_SCAN_RETRY. Otherwise we will return empty
28202820
* keys and the user will need to make subsequent calls with an updated
2821-
*iterator.
2821+
*cursor.
28222822
*/
28232823
do {
28242824
/* Free our previous reply if we're back in the loop. We know we are
@@ -2829,10 +2829,10 @@ generic_scan_cmd(INTERNAL_FUNCTION_PARAMETERS, REDIS_SCAN_TYPE type) {
28292829
}
28302830

28312831
// Format our SCAN command
2832-
cmd_len=redis_build_scan_cmd(&cmd,type,key,key_len,(long)cursor,
2833-
pattern,pattern_len,count,match_type);
2832+
cmd_len=redis_build_scan_cmd(&cmd,type,key,key_len,cursor,
2833+
pattern,pattern_len,count,match_type);
28342834

2835-
/* Execute our command getting our newiterator value */
2835+
/* Execute our command getting our newcursor value */
28362836
REDIS_PROCESS_REQUEST(redis_sock,cmd,cmd_len);
28372837
if(redis_sock_read_scan_reply(INTERNAL_FUNCTION_PARAM_PASSTHRU,
28382838
redis_sock,type,&cursor)<0)
@@ -2853,7 +2853,7 @@ generic_scan_cmd(INTERNAL_FUNCTION_PARAMETERS, REDIS_SCAN_TYPE type) {
28532853
/* Free our key if it was prefixed */
28542854
if(key_free)efree(key);
28552855

2856-
/* Update ouriterator reference */
2856+
/* Update ourcursor reference */
28572857
redisSetScanCursor(z_cursor,cursor);
28582858
}
28592859

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp