@@ -62,6 +62,11 @@ impl KVStore for FilesystemStore {
62
62
let lock_key = ( namespace. to_string ( ) , key. to_string ( ) ) ;
63
63
let inner_lock_ref = Arc :: clone ( & outer_lock. entry ( lock_key) . or_default ( ) ) ;
64
64
65
+ if key. is_empty ( ) {
66
+ let msg = format ! ( "Failed to read {}/{}: key may not be empty." , namespace, key) ;
67
+ return Err ( std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , msg) ) ;
68
+ }
69
+
65
70
let mut dest_file_path = self . data_dir . clone ( ) ;
66
71
dest_file_path. push ( namespace) ;
67
72
dest_file_path. push ( key) ;
@@ -74,6 +79,11 @@ impl KVStore for FilesystemStore {
74
79
let inner_lock_ref = Arc :: clone ( & outer_lock. entry ( lock_key) . or_default ( ) ) ;
75
80
let _guard = inner_lock_ref. write ( ) . unwrap ( ) ;
76
81
82
+ if key. is_empty ( ) {
83
+ let msg = format ! ( "Failed to write {}/{}: key may not be empty." , namespace, key) ;
84
+ return Err ( std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , msg) ) ;
85
+ }
86
+
77
87
let mut dest_file_path = self . data_dir . clone ( ) ;
78
88
dest_file_path. push ( namespace) ;
79
89
dest_file_path. push ( key) ;
@@ -148,6 +158,11 @@ impl KVStore for FilesystemStore {
148
158
149
159
let _guard = inner_lock_ref. write ( ) . unwrap ( ) ;
150
160
161
+ if key. is_empty ( ) {
162
+ let msg = format ! ( "Failed to remove {}/{}: key may not be empty." , namespace, key) ;
163
+ return Err ( std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , msg) ) ;
164
+ }
165
+
151
166
let mut dest_file_path = self . data_dir . clone ( ) ;
152
167
dest_file_path. push ( namespace) ;
153
168
dest_file_path. push ( key) ;
0 commit comments