telnet: use asprintf for r349890 change

Suggested by:	imp
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Ed Maste 2019-08-01 13:46:04 +00:00
parent 1082be6554
commit deffed6ea2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=350498

View file

@ -1655,14 +1655,11 @@ env_init(void)
|| (strncmp((char *)ep->value, "unix:", 5) == 0))) {
char hbuf[256+1];
char *cp2 = strchr((char *)ep->value, ':');
size_t buflen;
gethostname(hbuf, sizeof(hbuf));
hbuf[sizeof(hbuf)-1] = '\0';
buflen = strlen(hbuf) + strlen(cp2) + 1;
cp = (char *)malloc(sizeof(char)*buflen);
asprintf(&cp, "%s%s", hbuf, cp2);
assert(cp != NULL);
snprintf((char *)cp, buflen, "%s%s", hbuf, cp2);
free(ep->value);
ep->value = (unsigned char *)cp;
}