commit - 1d7c4420d1d212aa08060d214236bf677e768ac3
commit + aac02238e5d3974fdc3636fe328c80c768389173
blob - 70c6265c3781e01cedf23fba2769c037a95528b0
blob + 5f13405753a28a8fea6effbce3e04fe25c3a70aa
--- lib/read_gotconfig_privsep.c
+++ lib/read_gotconfig_privsep.c
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
+#include <string.h>
#include <imsg.h>
#include <sha1.h>
#include <sha2.h>
int fd = -1;
int imsg_fds[2] = { -1, -1 };
pid_t pid;
- struct imsgbuf *ibuf = NULL;
+ struct imsgbuf ibuf;
+ memset(&ibuf, 0, sizeof(ibuf));
+
*conf = calloc(1, sizeof(**conf));
if (*conf == NULL)
return got_error_from_errno("calloc");
goto done;
}
- ibuf = calloc(1, sizeof(*ibuf));
- if (ibuf == NULL) {
- err = got_error_from_errno("calloc");
- goto done;
- }
-
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, imsg_fds) == -1) {
err = got_error_from_errno("socketpair");
goto done;
goto wait;
}
imsg_fds[1] = -1;
- if (imsgbuf_init(ibuf, imsg_fds[0]) == -1) {
+ if (imsgbuf_init(&ibuf, imsg_fds[0]) == -1) {
err = got_error_from_errno("imsgbuf_init");
goto wait;
}
- imsgbuf_allow_fdpass(ibuf);
+ imsgbuf_allow_fdpass(&ibuf);
- err = got_privsep_send_gotconfig_parse_req(ibuf, fd);
+ err = got_privsep_send_gotconfig_parse_req(&ibuf, fd);
if (err)
goto wait;
fd = -1;
- err = got_privsep_send_gotconfig_author_req(ibuf);
+ err = got_privsep_send_gotconfig_author_req(&ibuf);
if (err)
goto wait;
- err = got_privsep_recv_gotconfig_str(&(*conf)->author, ibuf);
+ err = got_privsep_recv_gotconfig_str(&(*conf)->author, &ibuf);
if (err)
goto wait;
- err = got_privsep_send_gotconfig_allowed_signers_req(ibuf);
+ err = got_privsep_send_gotconfig_allowed_signers_req(&ibuf);
if (err)
goto wait;
err = got_privsep_recv_gotconfig_str(&(*conf)->allowed_signers_file,
- ibuf);
+ &ibuf);
if (err)
goto wait;
- err = got_privsep_send_gotconfig_revoked_signers_req(ibuf);
+ err = got_privsep_send_gotconfig_revoked_signers_req(&ibuf);
if (err)
goto wait;
err = got_privsep_recv_gotconfig_str(&(*conf)->revoked_signers_file,
- ibuf);
+ &ibuf);
if (err)
goto wait;
- err = got_privsep_send_gotconfig_signer_id_req(ibuf);
+ err = got_privsep_send_gotconfig_signer_id_req(&ibuf);
if (err)
goto wait;
- err = got_privsep_recv_gotconfig_str(&(*conf)->signer_id, ibuf);
+ err = got_privsep_recv_gotconfig_str(&(*conf)->signer_id, &ibuf);
if (err)
goto wait;
- err = got_privsep_send_gotconfig_remotes_req(ibuf);
+ err = got_privsep_send_gotconfig_remotes_req(&ibuf);
if (err)
goto wait;
err = got_privsep_recv_gotconfig_remotes(&(*conf)->remotes,
- &(*conf)->nremotes, ibuf);
+ &(*conf)->nremotes, &ibuf);
if (err)
goto wait;
wait:
got_gotconfig_free(*conf);
*conf = NULL;
}
- imsgbuf_clear(ibuf);
- free(ibuf);
+ if (ibuf.w)
+ imsgbuf_clear(&ibuf);
return err;
}