mediocregopher / radix.v2

Redis client for Go
http://godoc.org/github.com/mediocregopher/radix.v2
MIT License
433 stars 92 forks source link

Fix potential out of range panic in Slot function #69

Closed nickynick closed 7 years ago

nickynick commented 7 years ago

If a key name ends in {, key[start+2:] goes out of range and panics. Sounds rather weird to have a key name like this, but this actually happened to me when using binary keys :)

nickynick commented 7 years ago

Oh, and also it seems the old version actually has a bug. From the cluster spec:

For the key foo{}{bar} the whole key will be hashed as usually since the first occurrence of { is followed by } on the right without characters in the middle.

The old version results in }{bar being used for hashing.

mediocregopher commented 7 years ago

Great catch and great fix, thanks! I added your fix to the code in radix.v3 too, since that was just copy/pasted.