mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 18:11:28 +01:00
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:
parent
fe556d1ed9
commit
3817a690c9
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user