Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 1 Aug 2019 13:46:04 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r350498 - head/contrib/telnet/telnet
Message-ID:  <201908011346.x71Dk47Y011882@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Thu Aug  1 13:46:04 2019
New Revision: 350498
URL: https://svnweb.freebsd.org/changeset/base/350498

Log:
  telnet: use asprintf for r349890 change
  
  Suggested by:	imp
  MFC after:	3 weeks
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/contrib/telnet/telnet/commands.c

Modified: head/contrib/telnet/telnet/commands.c
==============================================================================
--- head/contrib/telnet/telnet/commands.c	Thu Aug  1 13:42:58 2019	(r350497)
+++ head/contrib/telnet/telnet/commands.c	Thu Aug  1 13:46:04 2019	(r350498)
@@ -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?201908011346.x71Dk47Y011882>