Skip to content

Commit 1cd6e1d

Browse files
endothermicdevniftynei
authored andcommitted
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
1 parent 0a4c030 commit 1cd6e1d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

common/gossip_store.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ size_t find_gossip_store_end(int gossip_store_fd, size_t off)
199199
} buf;
200200
int r;
201201

202-
while ((r = read(gossip_store_fd, &buf,
203-
sizeof(buf.hdr) + sizeof(buf.type)))
202+
while ((r = pread(gossip_store_fd, &buf,
203+
sizeof(buf.hdr) + sizeof(buf.type), off))
204204
== sizeof(buf.hdr) + sizeof(buf.type)) {
205205
u32 msglen = be32_to_cpu(buf.hdr.len) & GOSSIP_STORE_LEN_MASK;
206206

@@ -209,7 +209,6 @@ size_t find_gossip_store_end(int gossip_store_fd, size_t off)
209209
break;
210210

211211
off += sizeof(buf.hdr) + msglen;
212-
lseek(gossip_store_fd, off, SEEK_SET);
213212
}
214213
return off;
215214
}

0 commit comments

Comments
 (0)