-
Notifications
You must be signed in to change notification settings - Fork 24.5k
Description
Describe the bug
SETEX is documented as being equivalent to doing (atomically) SET followed by EXPIRE. However, the code for checking for overflow in EXPIRE is different and only reports an invalid expiry time if multiplying by 1000 gives a negative time.
To reproduce
SETEX rejects an expiry time that is more than 2^63 ms:
127.0.0.1:6379> setex foo 18446744073709561 blah
(error) ERR invalid expire time in setex
EXPIRE accepts it, and expires the key about 10 seconds later.
127.0.0.1:6379> set foo bar
OK
127.0.0.1:6379> expire foo 18446744073709561
(integer) 1
Expected behavior
Expected EXPIRE to match the behaviour of SETEX, and reject expiry times that overflow when converted to absolute milliseconds. It looks like this helper function might be useful for having EXPIRE apply the same logic.
Additional information
By eyeball, #9601 looks like it might fix the bug. The PR description suggests that the author might not have realised that this fixes an actual bug rather than just a UBSan violation, and that the intent was not to backport it to stable branches (cc @tezc @oranagra).