permit 0 length key, field and member

This commit is contained in:
siddontang 2014-05-23 12:23:20 +08:00
parent 81a5587c99
commit 581a492f78
3 changed files with 5 additions and 5 deletions

View File

@ -20,9 +20,9 @@ const (
)
func checkHashKFSize(key []byte, field []byte) error {
if len(key) > MaxKeySize {
if len(key) > MaxKeySize || len(key) == 0 {
return ErrKeySize
} else if len(field) > MaxHashFieldSize {
} else if len(field) > MaxHashFieldSize || len(field) == 0 {
return ErrHashFieldSize
}
return nil

View File

@ -13,7 +13,7 @@ type KVPair struct {
var errKVKey = errors.New("invalid encode kv key")
func checkKeySize(key []byte) error {
if len(key) > MaxKeySize {
if len(key) > MaxKeySize || len(key) == 0 {
return ErrKeySize
}
return nil

View File

@ -32,9 +32,9 @@ const (
)
func checkZSetKMSize(key []byte, member []byte) error {
if len(key) > MaxKeySize {
if len(key) > MaxKeySize || len(key) == 0 {
return ErrKeySize
} else if len(member) > MaxZSetMemberSize {
} else if len(member) > MaxZSetMemberSize || len(member) == 0 {
return ErrZSetMemberSize
}
return nil