mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-08-12 00:20:17 -04:00
fw: Add pointer argument NULL checks
This commit is contained in:
parent
e52b68650f
commit
b865111c0f
7 changed files with 97 additions and 0 deletions
|
@ -23,6 +23,10 @@ void part_digest(struct partition_table *part_table, uint8_t *out_digest, size_t
|
|||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
|
||||
assert(part_table != NULL);
|
||||
assert(out_digest != NULL);
|
||||
|
||||
blake2err = blake2s(out_digest, out_len,
|
||||
key, sizeof(key), part_table, sizeof(struct partition_table));
|
||||
|
||||
|
@ -43,6 +47,10 @@ int part_table_read(struct partition_table_storage *storage)
|
|||
};
|
||||
uint8_t check_digest[PART_DIGEST_SIZE];
|
||||
|
||||
if (storage == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
flash_release_powerdown();
|
||||
memset(storage, 0x00, sizeof(*storage));
|
||||
|
||||
|
@ -70,6 +78,10 @@ int part_table_write(struct partition_table_storage *storage)
|
|||
ADDR_PARTITION_TABLE_1,
|
||||
};
|
||||
|
||||
if (storage == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
part_digest(&storage->table, storage->check_digest, sizeof(storage->check_digest));
|
||||
|
||||
for (int i = 0; i < 2; i ++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue