danitseitlin / redis-interval-sets

Redis module for creating interval sets, handling them and filtering out relevant sets by number in range.
BSD 3-Clause "New" or "Revised" License
20 stars 2 forks source link

Key names aren't binary safe when using { or } #27

Open stopforumspam opened 2 years ago

stopforumspam commented 2 years ago

Using a { or } in a key name causes the internal json parser to segfault

A member with a binary encoded member that has a } in it, one that is then followed by another member with a } in it, will generate invalid JSON (in the loop for i in s.chars() ) that is then parsed, causing the panic as the min and/or max scores cannot be parsed.

Adding a small console log shows the string positions being miscalculated, eg

processing i = A�','min_score':37227008,'max_score':37227263},{'member':'us}....

attached is an RDB dump that will segfault on load

try iadd.set }}}} }{ 10 20 iadd.set }}}} }{{} 15 35

savedb and then load

https://github.com/danitseitlin/redis-interval-sets/files/8101646/dump.zip