Skip to content

Commit f3c0dd2

Browse files
zinedmichael-grunder
authored andcommitted
let setex properly handle long expire values
adjust the format string passed to redis_cmd_format_static() to properly handle long int, in order to prevent integer overflows resulting in negative expire times passed to redis.
1 parent 853f86b commit f3c0dd2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

redis.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ PHP_METHOD(Redis, set) {
890890
val, val_len, set_type, 2);
891891
} else if(expire > 0) {
892892
/* Backward compatible SETEX redirection */
893-
cmd_len = redis_cmd_format_static(&cmd, "SETEX", "sds", key, key_len,
893+
cmd_len = redis_cmd_format_static(&cmd, "SETEX", "sls", key, key_len,
894894
expire, val, val_len);
895895
} else {
896896
/* SET <key> <value> */
@@ -932,7 +932,7 @@ PHPAPI void redis_generic_setex(INTERNAL_FUNCTION_PARAMETERS, char *keyword) {
932932

933933
val_free = redis_serialize(redis_sock, z_value, &val, &val_len TSRMLS_CC);
934934
key_free = redis_key_prefix(redis_sock, &key, &key_len TSRMLS_CC);
935-
cmd_len = redis_cmd_format_static(&cmd, keyword, "sds", key, key_len, expire, val, val_len);
935+
cmd_len = redis_cmd_format_static(&cmd, keyword, "sls", key, key_len, expire, val, val_len);
936936
if(val_free) efree(val);
937937
if(key_free) efree(key);
938938

0 commit comments

Comments
 (0)