svn commit: r350900 - stable/12/contrib/telnet/telnet

Ed Maste emaste at FreeBSD.org
Mon Aug 12 15:52:22 UTC 2019


Author: emaste
Date: Mon Aug 12 15:52:21 2019
New Revision: 350900
URL: https://svnweb.freebsd.org/changeset/base/350900

Log:
  MFC r350498: telnet: use asprintf for r350139 [MFC of r349890] change
  
  Sponsored by:	The FreeBSD Foundation

Modified:
  stable/12/contrib/telnet/telnet/commands.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/contrib/telnet/telnet/commands.c
==============================================================================
--- stable/12/contrib/telnet/telnet/commands.c	Mon Aug 12 12:51:47 2019	(r350899)
+++ stable/12/contrib/telnet/telnet/commands.c	Mon Aug 12 15:52:21 2019	(r350900)
@@ -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;
 	}


More information about the svn-src-all mailing list