Skip to content

Commit fd9bc08

Browse files
author
Seppo Takalo
committed
TDBStore: Don't copy more data than what we can hold
1 parent ee77e61 commit fd9bc08

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

features/storage/kvstore/tdbstore/TDBStore.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,10 @@ int TDBStore::copy_record(uint8_t from_area, uint32_t from_offset, uint32_t to_o
798798
align_up(header.key_size + header.data_size, _prog_size);;
799799

800800

801+
if (to_offset + total_size > _size) {
802+
// We are trying to copy more that the are can hold
803+
return MBED_ERROR_MEDIA_FULL;
804+
}
801805
ret = check_erase_before_write(1 - from_area, to_offset, total_size);
802806
if (ret) {
803807
return ret;

0 commit comments

Comments
 (0)