commit - 50f1d7bec5bdd5acea20392af171a75c41deef1a
commit + 2032130aa35c234e5e508afd485a6996ed2e91d8
blob - 156666bf66fc9c6047015be78b05d579669ba07e
blob + a9f801243fe0f3232af577fb8cdcfc0cadbb2442
--- gotsysd/helpers.c
+++ gotsysd/helpers.c
close(proc->iev.ibuf.fd);
}
+ if (proc->fd != -1)
+ close(proc->fd);
free(proc);
}
const struct got_error *err = NULL;
struct gotsysd_helper_proc *proc;
struct timeval tv = { 5, 0 };
- int fd = -1;
proc = calloc(1, sizeof(*proc));
if (proc == NULL) {
err = got_error_from_errno("calloc");
goto done;
}
+ proc->fd = -1;
log_debug("starting %s", argv0);
proc->type = imsg->hdr.type;
switch (proc->type) {
case GOTSYSD_IMSG_START_PROG_READ_CONF:
- fd = imsg_get_fd(imsg);
- if (fd == -1) {
+ proc->fd = imsg_get_fd(imsg);
+ if (proc->fd == -1) {
err = got_error(GOT_ERR_PRIVSEP_NO_FD);
goto done;
}
break;
}
- proc->pid = start_child(argv0, argv1, argv2, proc->pipe[1], fd);
+ proc->pid = start_child(argv0, argv1, argv2, proc->pipe[1], proc->fd);
proc->pipe[1] = -1;
strlcpy(proc->progname, argv0, sizeof(proc->progname));
evtimer_set(&proc->startup_tmo, proc_startup_timeout, proc);
evtimer_add(&proc->startup_tmo, &tv);
done:
- if (err)
+ if (err) {
+ if (proc->fd != -1)
+ close(proc->fd);
free(proc);
+ }
return err;
}