Skip to content

Commit

Permalink
gossip_store: fix offset error
Browse files Browse the repository at this point in the history
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
  • Loading branch information
endothermicdev authored and cdecker committed Sep 14, 2022
1 parent f64d755 commit 4167fe8
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions common/gossip_store.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}
Expand Down

0 comments on commit 4167fe8

Please sign in to comment.