telnet: use asprintf for r349890 change
Suggested by: imp MFC after: 3 weeks Sponsored by: The FreeBSD Foundation
This commit is contained in:
parent
1082be6554
commit
deffed6ea2
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user