commit 6c13dcd2d0d730f9f9fc0fb0c42eb0f409216063 from: Stefan Sperling date: Fri Sep 18 18:24:09 2020 UTC send gitconfig imsg string values the same way as gotconfig ones are sent commit - 5874ea87557e324b6e847a5dbed5a1b4b9efe92e commit + 6c13dcd2d0d730f9f9fc0fb0c42eb0f409216063 blob - aae7f1d76161cbcce05967dbd8746225b7f5385f blob + 77debd84e15bb4334632363ebe637cfbe88f4202 --- lib/privsep.c +++ lib/privsep.c @@ -1734,13 +1734,14 @@ got_privsep_recv_gitconfig_str(char **str, struct imsg 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 @@ -73,7 +73,7 @@ gitconfig_num_request(struct imsgbuf *ibuf, struct got 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)