commit - a9705505a48884d66efa5d535fff9d685b35808d
commit + 5874ea87557e324b6e847a5dbed5a1b4b9efe92e
blob - adef301b3a4e820cb8b7d8a826cfbdfe0c69a60e
blob + aae7f1d76161cbcce05967dbd8746225b7f5385f
--- lib/privsep.c
+++ lib/privsep.c
case GOT_IMSG_GOTCONFIG_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);