From 8cc02f63bc7eb2d186a096e7e1299196978e7325 Mon Sep 17 00:00:00 2001 From: practicalswift Date: Sun, 6 May 2018 09:03:03 +0200 Subject: [PATCH] gossipd: Handle failed lseek(...) --- gossipd/gossip_store.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gossipd/gossip_store.c b/gossipd/gossip_store.c index 5fb94f924..9153cba63 100644 --- a/gossipd/gossip_store.c +++ b/gossipd/gossip_store.c @@ -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);