mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-16 06:52:27 +00:00
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
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=350498
|
@ -1655,14 +1655,11 @@ env_init(void)
|
||||||
|| (strncmp((char *)ep->value, "unix:", 5) == 0))) {
|
|| (strncmp((char *)ep->value, "unix:", 5) == 0))) {
|
||||||
char hbuf[256+1];
|
char hbuf[256+1];
|
||||||
char *cp2 = strchr((char *)ep->value, ':');
|
char *cp2 = strchr((char *)ep->value, ':');
|
||||||
size_t buflen;
|
|
||||||
|
|
||||||
gethostname(hbuf, sizeof(hbuf));
|
gethostname(hbuf, sizeof(hbuf));
|
||||||
hbuf[sizeof(hbuf)-1] = '\0';
|
hbuf[sizeof(hbuf)-1] = '\0';
|
||||||
buflen = strlen(hbuf) + strlen(cp2) + 1;
|
asprintf(&cp, "%s%s", hbuf, cp2);
|
||||||
cp = (char *)malloc(sizeof(char)*buflen);
|
|
||||||
assert(cp != NULL);
|
assert(cp != NULL);
|
||||||
snprintf((char *)cp, buflen, "%s%s", hbuf, cp2);
|
|
||||||
free(ep->value);
|
free(ep->value);
|
||||||
ep->value = (unsigned char *)cp;
|
ep->value = (unsigned char *)cp;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue