Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4ac242f

Browse files
committed
capsules: kv_store: handle if buffer too short
1 parent 245d27c commit 4ac242f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

capsules/extra/src/kv_store.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,12 @@ impl<'a, K: KVSystem<'a, K = T>, T: kv_system::KeyType> kv_system::Client<T>
432432
Operation::Delete => {
433433
let mut access_allowed = false;
434434

435-
if result.is_ok() {
435+
// Before we delete an object we retrieve the header to
436+
// ensure that we have permissions to access it. In that
437+
// case we don't need to supply a buffer long enough to
438+
// store the full value, so a `SIZE` error code is ok
439+
// and we can continue to remove the object.
440+
if result.is_ok() || result.err() == Some(ErrorCode::SIZE) {
436441
let header = KeyHeader::new_from_buf(ret_buf);
437442

438443
if header.version == HEADER_VERSION {
@@ -476,7 +481,7 @@ impl<'a, K: KVSystem<'a, K = T>, T: kv_system::KeyType> kv_system::Client<T>
476481

477482
let mut read_allowed = false;
478483

479-
if result.is_ok() {
484+
if result.is_ok() || result.err() == Some(ErrorCode::SIZE) {
480485
let header = KeyHeader::new_from_buf(ret_buf);
481486

482487
if header.version == HEADER_VERSION {

0 commit comments

Comments
 (0)