Skip to content

Commit 06dc6f5

Browse files
committed
Remove unnecessary backup deletion before rename
The fs->remove("/contacts3.bak") before the rename sequence creates a vulnerability window: if power is lost right after removing the backup but before the rename completes, both the backup and primary file could be lost. The remove is unnecessary since rename() on both SPIFFS and LittleFS replaces the target if it already exists.
1 parent ab7c415 commit 06dc6f5

1 file changed

Lines changed: 0 additions & 1 deletion

File tree

examples/companion_radio/DataStore.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,6 @@ void DataStore::saveContacts(DataStoreHost* host) {
359359

360360
#ifdef HAS_ATOMIC_WRITE_SUPPORT
361361
if (write_success) {
362-
fs->remove("/contacts3.bak");
363362
fs->rename("/contacts3", "/contacts3.bak");
364363
fs->rename("/contacts3.tmp", "/contacts3");
365364
fs->remove("/contacts3.bak");

0 commit comments

Comments
 (0)