commit - 5874ea87557e324b6e847a5dbed5a1b4b9efe92e
commit + 6c13dcd2d0d730f9f9fc0fb0c42eb0f409216063
blob - aae7f1d76161cbcce05967dbd8746225b7f5385f
blob + 77debd84e15bb4334632363ebe637cfbe88f4202
--- lib/privsep.c
+++ lib/privsep.c
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);
blob - 351b3970ccd0b2b92127f68fdd6273edc4731b06
blob + e24545d20956871d467322bef47e09dbcb3c46ed
--- libexec/got-read-gitconfig/got-read-gitconfig.c
+++ libexec/got-read-gitconfig/got-read-gitconfig.c
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)