commit - 5735c9f6fa945e745aa45bc164ccccb7fddbefca
commit + daf4cb35f2cef3ba7b74aa8900e9c762e48a32ec
blob - a73395f68544e7ab4cfba3397442e39af584d394
blob + b6c82dd28a9f8aef9f345568105d44610402a314
--- gotd/repo_read.c
+++ gotd/repo_read.c
size_t datalen;
struct gotd_imsg_reflist irefs;
struct imsgbuf ibuf;
- int client_fd;
struct got_object_id *head_target_id = NULL;
TAILQ_INIT(&refs);
- client_fd = imsg_get_fd(imsg);
- if (client_fd == -1)
- return got_error(GOT_ERR_PRIVSEP_NO_FD);
-
datalen = imsg->hdr.len - IMSG_HEADER_SIZE;
if (datalen != 0)
return got_error(GOT_ERR_PRIVSEP_LEN);
}
repo_read.refs_listed = 1;
- client->fd = client_fd;
+ client->fd = imsg_get_fd(imsg);
+ if (client->fd == -1)
+ return got_error(GOT_ERR_PRIVSEP_NO_FD);
- imsg_init(&ibuf, client_fd);
+ imsg_init(&ibuf, client->fd);
err = got_ref_list(&refs, repo_read.repo, "",
got_ref_cmp_by_name, NULL);
blob - ea922fda862cec518bb34fccb83d41257d6bec44
blob + 58219b54d1c2ae9d34d51338eb944eda43105fca
--- gotd/repo_write.c
+++ gotd/repo_write.c
size_t datalen;
struct gotd_imsg_reflist irefs;
struct imsgbuf ibuf;
- int client_fd;
TAILQ_INIT(&refs);
- client_fd = imsg_get_fd(imsg);
- if (client_fd == -1)
- return got_error(GOT_ERR_PRIVSEP_NO_FD);
-
datalen = imsg->hdr.len - IMSG_HEADER_SIZE;
if (datalen != 0)
return got_error(GOT_ERR_PRIVSEP_LEN);
}
repo_write.refs_listed = 1;
- client->fd = client_fd;
+ client->fd = imsg_get_fd(imsg);
+ if (client->fd == -1)
+ return got_error(GOT_ERR_PRIVSEP_NO_FD);
+
client->nref_updates = 0;
client->nref_del = 0;
client->nref_new = 0;
client->nref_move = 0;
- imsg_init(&ibuf, client_fd);
+ imsg_init(&ibuf, client->fd);
err = got_ref_list(&refs, repo_write.repo, "",
got_ref_cmp_by_name, NULL);
err = got_delta_cache_alloc(&pack->delta_cache);
if (err)
- return err;
+ goto done;
for (i = 0; i < nitems(repo_tempfiles); i++) {
struct repo_tempfile *t = &repo_tempfiles[i];
blob - 2bb64eceaff2476797ea46cd6e94349d6d17ae7e
blob + 737c3fde2ecd44b03cf457be5b3727221a611dc2
--- lib/object_open_privsep.c
+++ lib/object_open_privsep.c
pid = fork();
if (pid == -1) {
err = got_error_from_errno("fork");
+ close(imsg_fds[0]);
+ close(imsg_fds[1]);
free(ibuf);
return err;
}
if (close(imsg_fds[1]) == -1) {
err = got_error_from_errno("close");
+ close(imsg_fds[0]);
free(ibuf);
return err;
}
blob - 7eb2c8a99caefb269b150c01c90af12ab9e277c5
blob + 76207e49a17dadd18e86609ab7833b09d308c6d2
--- lib/pack.c
+++ lib/pack.c
pid = fork();
if (pid == -1) {
err = got_error_from_errno("fork");
+ close(imsg_fds[0]);
+ close(imsg_fds[1]);
goto done;
} else if (pid == 0) {
set_max_datasize();
/* not reached */
}
- if (close(imsg_fds[1]) == -1)
- return got_error_from_errno("close");
+ if (close(imsg_fds[1]) == -1) {
+ err = got_error_from_errno("close");
+ close(imsg_fds[0]);
+ goto done;
+ }
pack->privsep_child->imsg_fd = imsg_fds[0];
pack->privsep_child->pid = pid;
imsg_init(ibuf, imsg_fds[0]);
blob - 4f69e0379f9bf1a344bab19dedbe8006d963fd97
blob + 746c2864eb29a5a281a4c584b7a025275d80fff6
--- lib/send.c
+++ lib/send.c
struct got_repository *repo, got_send_progress_cb progress_cb,
void *progress_arg, got_cancel_cb cancel_cb, void *cancel_arg)
{
- int imsg_sendfds[2];
+ int imsg_sendfds[2] = { -1, -1 };
int npackfd = -1, nsendfd = -1;
int sendstatus, done = 0;
const struct got_error *err;
if (sendpid == -1) {
err = got_error_from_errno("fork");
goto done;
- } else if (sendpid == 0){
+ } else if (sendpid == 0) {
got_privsep_exec_child(imsg_sendfds,
GOT_PATH_PROG_SEND_PACK, got_repo_get_path(repo));
}
err = got_error_from_errno("close");
goto done;
}
+ imsg_sendfds[1] = -1;
imsg_init(&sendibuf, imsg_sendfds[0]);
nsendfd = dup(sendfd);
if (nsendfd == -1) {
if (waitpid(sendpid, &sendstatus, 0) == -1 && err == NULL)
err = got_error_from_errno("waitpid");
}
+ if (imsg_sendfds[0] != -1 && close(imsg_sendfds[0]) == -1 && err == NULL)
+ err = got_error_from_errno("close");
+ if (imsg_sendfds[1] != -1 && close(imsg_sendfds[1]) == -1 && err == NULL)
+ err = got_error_from_errno("close");
if (packfd != -1 && close(packfd) == -1 && err == NULL)
err = got_error_from_errno("close");
if (delta_cache && fclose(delta_cache) == EOF && err == NULL)