fw: Add pointer argument NULL checks

This commit is contained in:
Mikael Ågren 2025-04-09 15:22:33 +02:00
parent e52b68650f
commit b865111c0f
No known key found for this signature in database
GPG key ID: E02DA3D397792C46
7 changed files with 97 additions and 0 deletions

View file

@ -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 ++) {