gossipd: actually validate gossip_store checksums at startup.

We rewrite the file to compact it, but as a side effect we
recalculate the checksums!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2022-09-14 13:20:31 +09:30
parent fe556d1ed9
commit 3817a690c9

View File

@ -175,6 +175,16 @@ static u32 gossip_store_compact_offline(struct routing_state *rstate)
continue;
}
/* Check checksum (upgrade would overwrite, so do it now) */
if (be32_to_cpu(hdr.crc)
!= crc32c(be32_to_cpu(hdr.timestamp), msg, msglen)) {
status_broken("gossip_store_compact_offline: checksum verification failed? %08x should be %08x",
be32_to_cpu(hdr.crc),
crc32c(be32_to_cpu(hdr.timestamp), msg + sizeof(hdr), msglen));
tal_free(msg);
goto close_and_delete;
}
if (oldversion != version) {
if (!upgrade_field(oldversion, rstate, &msg)) {
tal_free(msg);