Skip to content

Commit db4dafc

Browse files
author
Kyle Kearney
committed
SecureStore: Add member initializers for inc_handle_t
_inc_set_handle is new'd in SecureStore::init(), then its members are referenced in various functions without being explicitly initialized first. These pre-existing values can confuse the SecureStore's internal state and cause various undesired behavior.
1 parent 18d4adf commit db4dafc

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

features/storage/kvstore/securestore/SecureStore.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,19 @@ static const uint32_t security_flags = KVStore::REQUIRE_CONFIDENTIALITY_FLAG | K
5252
namespace {
5353

5454
typedef struct {
55-
uint16_t metadata_size;
56-
uint16_t revision;
57-
uint32_t data_size;
58-
uint32_t create_flags;
59-
uint8_t iv[iv_size];
55+
uint16_t metadata_size = 0u;
56+
uint16_t revision = 0u;
57+
uint32_t data_size = 0u;
58+
uint32_t create_flags = 0u;
59+
uint8_t iv[iv_size] = { 0u };
6060
} record_metadata_t;
6161

6262
// incremental set handle
6363
typedef struct {
6464
record_metadata_t metadata;
65-
char *key;
66-
uint32_t offset_in_data;
67-
uint8_t ctr_buf[enc_block_size];
65+
char *key = nullptr;
66+
uint32_t offset_in_data = 0u;
67+
uint8_t ctr_buf[enc_block_size] = { 0u };
6868
mbedtls_aes_context enc_ctx;
6969
mbedtls_cipher_context_t auth_ctx;
7070
KVStore::set_handle_t underlying_handle;

0 commit comments

Comments
 (0)