Browse Source

Make sure fsync, connect and close are never accidentally passed negative arguments

ppa-0.6.1
practicalswift 7 years ago
committed by Christian Decker
parent
commit
4bdd2452f2
  1. 4
      hsmd/hsm.c
  2. 3
      lightningd/jsonrpc.c
  3. 2
      lightningd/subd.c

4
hsmd/hsm.c

@ -489,6 +489,10 @@ static void create_new_hsm(struct daemon_conn *master)
"closing: %s", strerror(errno));
}
fd = open(".", O_RDONLY);
if (fd < 0) {
status_failed(STATUS_FAIL_INTERNAL_ERROR,
"opening: %s", strerror(errno));
}
if (fsync(fd) != 0) {
unlink_noerr("hsm_secret");
status_failed(STATUS_FAIL_INTERNAL_ERROR,

3
lightningd/jsonrpc.c

@ -673,6 +673,9 @@ void setup_jsonrpc(struct lightningd *ld, const char *rpc_filename)
}
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
errx(1, "domain socket creation failed");
}
if (strlen(rpc_filename) + 1 > sizeof(addr.sun_path))
errx(1, "rpc filename '%s' too long", rpc_filename);
strcpy(addr.sun_path, rpc_filename);

2
lightningd/subd.c

@ -121,7 +121,7 @@ static void close_taken_fds(va_list *ap)
int *fd;
while ((fd = va_arg(*ap, int *)) != NULL) {
if (taken(fd)) {
if (taken(fd) && *fd >= 0) {
close(*fd);
*fd = -1;
}

Loading…
Cancel
Save