Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Aug 2019 15:54:30 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r350901 - stable/11/contrib/telnet/telnet
Message-ID:  <201908121554.x7CFsUIn056142@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Mon Aug 12 15:54:30 2019
New Revision: 350901
URL: https://svnweb.freebsd.org/changeset/base/350901

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

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

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201908121554.x7CFsUIn056142>