[redis]github-761 Report
https://github.com/antirez/redis/issues/761
Redis server crashes on a large integer input to “zinterstore” command
Severe
Yes: crash
No
Single server
2.6.0-rc7
Standard
zinterstore out 9223372036854775807 zset zset2 (feature start)
Single event
Yes
yes
1
Crash, and the crash log contains the command and stack trace
It’s quite easy to notice the wrong thing from the crash report:
=r cmd=zinterstore
[17998] 12 Sep 16:35:58.838 # argv[0]: 'zinterstore'
[17998] 12 Sep 16:35:58.838 # argv[1]: 'out'
[17998] 12 Sep 16:35:58.838 # argv[2]: '9223372036854775807'
[17998] 12 Sep 16:35:58.838 # argv[3]: 'zset'
[17998] 12 Sep 16:35:58.838 # argv[4]: 'zset2'
And this will manifest as “setnum” here:
/* test if the expected number of keys would overflow */
if (3+setnum > c->argc) {
addReply(c,shared.syntaxerr);
return;
}
If you add 3, there will be integer overflow… c->argc is 5 and setnum is 9223372036854775807. They should have rejected the error here, but when the integer overflowed, and they passed this condition...
Integer overflow.
Semantic (integer overflow)
/* test if the expected number of keys would overflow */
- if (3+setnum > c->argc) {
+ if (setnum > c->argc-3) {
addReply(c,shared.syntaxerr);
return;
}