@@ -40,8 +40,11 @@ const uint16_t DB_VERSION = 1;
40
40
41
41
#define DB_STORE_OFFSET_PEER_SIGNING_COUNT (DB_STORE_OFFSET_PEER_SIGNING + sizeof (csrk_t ))
42
42
43
+ /* make size multiple of 4 */
44
+ #define PAD4 (value ) ((((value - 1 ) / 4 ) * 4 ) + 4 )
45
+
43
46
#define DB_SIZE_STORE \
44
- (sizeof (SecurityEntryKeys_t) + \
47
+ PAD4 (sizeof (SecurityEntryKeys_t) + \
45
48
sizeof (SecurityEntryKeys_t) + \
46
49
sizeof (SecurityEntryIdentity_t) + \
47
50
sizeof (SecurityEntrySigning_t) + \
@@ -65,8 +68,7 @@ const uint16_t DB_VERSION = 1;
65
68
#define DB_OFFSET_ENTRIES (DB_OFFSET_LOCAL_SIGN_COUNT + sizeof (sign_count_t ))
66
69
#define DB_OFFSET_STORES (DB_OFFSET_ENTRIES + DB_SIZE_ENTRIES)
67
70
#define DB_OFFSET_MAX (DB_OFFSET_STORES + DB_SIZE_STORES)
68
- /* make size multiple of 4 */
69
- #define DB_SIZE ((((DB_OFFSET_MAX - 1 ) / 4 ) * 4 ) + 4 )
71
+ #define DB_SIZE PAD4 (DB_OFFSET_MAX)
70
72
71
73
typedef SecurityDb::entry_handle_t entry_handle_t;
72
74
@@ -311,6 +313,14 @@ void FileSecurityDb::reset_entry(entry_handle_t db_entry) {
311
313
if (!entry) {
312
314
return ;
313
315
}
316
+
317
+ fseek (_db_file, entry->file_offset , SEEK_SET);
318
+ const uint32_t zero = 0 ;
319
+ size_t count = DB_SIZE_STORE / 4 ;
320
+ while (count--) {
321
+ fwrite (&zero, sizeof (zero), 1 , _db_file);
322
+ }
323
+
314
324
entry->flags = SecurityDistributionFlags_t ();
315
325
entry->peer_sign_counter = 0 ;
316
326
}
0 commit comments