Skip to content

Commit

Permalink
gossipd: Handle failed lseek(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
practicalswift authored and cdecker committed May 6, 2018
1 parent e308423 commit 8cc02f6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion gossipd/gossip_store.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ void gossip_store_load(struct routing_state *rstate, struct gossip_store *gs)
const char *bad;
size_t stats[] = {0, 0, 0, 0};

lseek(gs->fd, known_good, SEEK_SET);
if (lseek(gs->fd, known_good, SEEK_SET) < 0) {
status_unusual("gossip_store: lseek failure");
goto truncate_nomsg;
}
while (read(gs->fd, &belen, sizeof(belen)) == sizeof(belen)) {
msglen = be32_to_cpu(belen);
msg = tal_arr(gs, u8, msglen);
Expand Down

0 comments on commit 8cc02f6

Please sign in to comment.