mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 09:10:28 +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))) {
|
||||
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 a new issue