Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix LPOS rank passing LLONG_MIN overflow issue (#1687)
There is a minor overflow issue in RANK negation, passing LLONG_MIN will overflow and is effectively be the same as passing -1. This is the example before the fix: ``` 127.0.0.1:6666> flushall OK 127.0.0.1:6666> lpos mylist foo rank -9223372036854775808 (nil) 127.0.0.1:6666> lpush mylist foo foo foo foo foo (integer) 5 127.0.0.1:6666> lpos mylist foo rank -1 (integer) 4 127.0.0.1:6666> lpos mylist foo rank -5 (integer) 0 127.0.0.1:6666> lpos mylist foo rank -6 (nil) 127.0.0.1:6666> lpos mylist foo rank -9223372036854775807 (nil) -- this should return nil but it returned the last one because the overflow rank became -1 127.0.0.1:6666> lpos mylist foo rank -9223372036854775808 (integer) 4 ``` Now we limit RANK to not be LLONG_MIN and will throw an error directly (this is the behavior of Redis 7.2, but with different error words): ``` 127.0.0.1:6666> lpos mylist foo rank -9223372036854775808 (error) ERR rank would overflow 127.0.0.1:6379> lpos mylist foo rank -9223372036854775808 (error) ERR value is out of range, value must between -9223372036854775807 and 9223372036854775807 ``` Unrelated change: a small cleanup, return RedisParseErr instead of RedisExecErr in Parse.
- Loading branch information