Fix UB in load_sha256 test caused by accessing incorrect union field

This commit is contained in:
Nathan Fisher 2023-08-22 13:17:54 -04:00
parent a8fcdbd140
commit 0a210b4e7e
2 changed files with 2 additions and 2 deletions

View file

@ -150,7 +150,7 @@ char* haggis_linkmap_get_or_add(haggis_linkmap *map, ino_t inode, char * path) {
ino_t val; ino_t val;
u8 bytes[sizeof(ino_t)]; u8 bytes[sizeof(ino_t)];
} key; } key;
char * target = NULL; char * target = "";
size_t idx, hash; size_t idx, hash;
haggis_bucket *b; haggis_bucket *b;

View file

@ -13,7 +13,7 @@ int main() {
if (haggis_load_cksum(f, &cksum)) return 1; if (haggis_load_cksum(f, &cksum)) return 1;
assert(cksum.tag == sha256); assert(cksum.tag == sha256);
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
assert(cksum.sum.sha1[i] == (uint8_t)i); assert(cksum.sum.sha256[i] == (uint8_t)i);
} }
fclose(f); fclose(f);
} }