mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-23 00:54:20 +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:
@@ -175,6 +175,16 @@ static u32 gossip_store_compact_offline(struct routing_state *rstate)
|
|||||||
continue;
|
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 (oldversion != version) {
|
||||||
if (!upgrade_field(oldversion, rstate, &msg)) {
|
if (!upgrade_field(oldversion, rstate, &msg)) {
|
||||||
tal_free(msg);
|
tal_free(msg);
|
||||||
|
|||||||
Reference in New Issue
Block a user