From 2ba3adab60f20b2ada706386a314d3d02c06438e Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Mon, 12 Aug 2019 15:52:21 +0000 Subject: [PATCH] MFC r350498: telnet: use asprintf for r350139 [MFC of r349890] change Sponsored by: The FreeBSD Foundation --- contrib/telnet/telnet/commands.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/contrib/telnet/telnet/commands.c b/contrib/telnet/telnet/commands.c index c6dc4ca064b..8b7c6595b90 100644 --- a/contrib/telnet/telnet/commands.c +++ b/contrib/telnet/telnet/commands.c @@ -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; } -- 2.45.0