add protection code for Range when the sortTarget is an invalid value

This commit is contained in:
ahrtr
2021-12-23 05:42:26 +08:00
parent 36351744eb
commit 15568f4c00
9 changed files with 167 additions and 19 deletions

View File

@ -51,7 +51,11 @@ func (kv *kvPrefix) Get(ctx context.Context, key string, opts ...clientv3.OpOpti
if len(key) == 0 && !(clientv3.IsOptsWithFromKey(opts) || clientv3.IsOptsWithPrefix(opts)) {
return nil, rpctypes.ErrEmptyKey
}
r, err := kv.KV.Do(ctx, kv.prefixOp(clientv3.OpGet(key, opts...)))
getOp := clientv3.OpGet(key, opts...)
if !getOp.IsSortOptionValid() {
return nil, rpctypes.ErrInvalidSortOption
}
r, err := kv.KV.Do(ctx, kv.prefixOp(getOp))
if err != nil {
return nil, err
}