enjoy-binbin opened a new pull request, #1687:
URL: https://github.com/apache/kvrocks/pull/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.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to