gossip_store: fix offset error

The gossip_store version byte was unaccounted for in the initial traversal
of gossip_store_end. This lead to an offset and a bogus message length
field. As a result, an early portion of the gossip_store could have been
skipped, potentially leading to gossip propagation issues downstream.

Fixes #5572 #5565

Changelog-fixed: proper gossip_store operation may resolve some previous gossip propagation issues
This commit is contained in:
Alex Myers 2022-09-13 18:39:59 -05:00 committed by Christian Decker
parent f64d755e43
commit 4167fe8dd9
1 changed files with 2 additions and 3 deletions

View File

@ -199,8 +199,8 @@ size_t find_gossip_store_end(int gossip_store_fd, size_t off)
} buf;
int r;
while ((r = read(gossip_store_fd, &buf,
sizeof(buf.hdr) + sizeof(buf.type)))
while ((r = pread(gossip_store_fd, &buf,
sizeof(buf.hdr) + sizeof(buf.type), off))
== sizeof(buf.hdr) + sizeof(buf.type)) {
u32 msglen = be32_to_cpu(buf.hdr.len) & GOSSIP_STORE_LEN_MASK;
@ -209,7 +209,6 @@ size_t find_gossip_store_end(int gossip_store_fd, size_t off)
break;
off += sizeof(buf.hdr) + msglen;
lseek(gossip_store_fd, off, SEEK_SET);
}
return off;
}