Skip to content

Commit 07c7af7

Browse files
committed
fix potential index out of range while meets corrupted keyspace prefix
Signed-off-by: iosmanthus <[email protected]>
1 parent 6baaa94 commit 07c7af7

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

src/request/codec.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ impl<M: Mode> RequestCodec for ApiV2<M> {
302302
if !key.starts_with(&prefix) {
303303
return Err(Error::CorruptedKeyspace {
304304
expected: prefix.to_vec(),
305-
actual: key[..KEYSPACE_PREFIX_LEN].to_vec(),
306305
key: key.to_vec(),
307306
});
308307
}

tikv-client-common/src/errors.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,8 @@ pub enum Error {
9393
inner: Box<Error>,
9494
success_keys: Vec<Vec<u8>>,
9595
},
96-
#[error(
97-
"Corrupted keyspace: expected: {:?}, actual: {:?}, key: {:?}",
98-
expected,
99-
actual,
100-
key
101-
)]
102-
CorruptedKeyspace {
103-
expected: Vec<u8>,
104-
actual: Vec<u8>,
105-
key: Vec<u8>,
106-
},
96+
#[error("Corrupted keyspace: expected: {:?}, key: {:?}", expected, key)]
97+
CorruptedKeyspace { expected: Vec<u8>, key: Vec<u8> },
10798
}
10899

109100
impl From<tikv_client_proto::errorpb::Error> for Error {

0 commit comments

Comments
 (0)