Browse Source

Check lseek(...) return value

ppa-0.6.1
practicalswift 7 years ago
committed by Christian Decker
parent
commit
dcb4039a96
  1. 8
      common/dev_disconnect.c
  2. 4
      lightningd/subd.c

8
common/dev_disconnect.c

@ -29,7 +29,9 @@ static void next_dev_disconnect(void)
dev_disconnect_line, sizeof(dev_disconnect_line)-1);
if (r < 0)
err(1, "Reading dev_disconnect file");
lseek(dev_disconnect_fd, -r, SEEK_CUR);
if (lseek(dev_disconnect_fd, -r, SEEK_CUR) < 0) {
err(1, "lseek failure");
}
/* Get first line */
dev_disconnect_line[r] = '\n';
@ -74,7 +76,9 @@ enum dev_disconnect dev_disconnect(int pkt_type)
return DEV_DISCONNECT_NORMAL;
}
lseek(dev_disconnect_fd, dev_disconnect_len+1, SEEK_CUR);
if (lseek(dev_disconnect_fd, dev_disconnect_len+1, SEEK_CUR) < 0) {
err(1, "lseek failure");
}
status_trace("dev_disconnect: %s%s", dev_disconnect_line,
dev_disconnect_nocommit ? "-nocommit" : "");

4
lightningd/subd.c

@ -776,7 +776,9 @@ bool dev_disconnect_permanent(struct lightningd *ld)
return true;
/* Nope, restore. */
lseek(ld->dev_disconnect_fd, -r, SEEK_CUR);
if (lseek(ld->dev_disconnect_fd, -r, SEEK_CUR) < 0) {
fatal("lseek failure");
}
return false;
}
#endif /* DEVELOPER */

Loading…
Cancel
Save