send gitconfig imsg string values the same way as gotconfig ones are sent
diff --git a/lib/privsep.c b/lib/privsep.c
index aae7f1d..77debd8 100644
--- a/lib/privsep.c
+++ b/lib/privsep.c
@@ -1734,13 +1734,14 @@ got_privsep_recv_gitconfig_str(char **str, struct imsgbuf *ibuf)
case GOT_IMSG_GITCONFIG_STR_VAL:
if (datalen == 0)
break;
- *str = malloc(datalen);
+ /* datalen does not include terminating \0 */
+ *str = malloc(datalen + 1);
if (*str == NULL) {
err = got_error_from_errno("malloc");
break;
}
- if (strlcpy(*str, imsg.data, datalen) >= datalen)
- err = got_error(GOT_ERR_NO_SPACE);
+ memcpy(*str, imsg.data, datalen);
+ (*str)[datalen] = '\0';
break;
default:
err = got_error(GOT_ERR_PRIVSEP_MSG);
diff --git a/libexec/got-read-gitconfig/got-read-gitconfig.c b/libexec/got-read-gitconfig/got-read-gitconfig.c
index 351b397..e24545d 100644
--- a/libexec/got-read-gitconfig/got-read-gitconfig.c
+++ b/libexec/got-read-gitconfig/got-read-gitconfig.c
@@ -73,7 +73,7 @@ gitconfig_num_request(struct imsgbuf *ibuf, struct got_gitconfig *gitconfig,
static const struct got_error *
send_gitconfig_str(struct imsgbuf *ibuf, const char *value)
{
- size_t len = value ? strlen(value) + 1 : 0;
+ size_t len = value ? strlen(value) : 0;
if (imsg_compose(ibuf, GOT_IMSG_GITCONFIG_STR_VAL, 0, 0, -1,
value, len) == -1)