Date: Wed, 10 Jul 2019 22:36:15 +0000 (UTC) From: Philip Paeps <philip@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r349896 - head/contrib/telnet/telnet Message-ID: <201907102236.x6AMaFLI067550@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: philip Date: Wed Jul 10 22:36:14 2019 New Revision: 349896 URL: https://svnweb.freebsd.org/changeset/base/349896 Log: telnet: fix minor style violation While here also fix a very unlikely NULL pointer dereference. Submitted by: Shawn Webb <shawn.webb@hardenedbsd.org> Modified: head/contrib/telnet/telnet/commands.c Modified: head/contrib/telnet/telnet/commands.c ============================================================================== --- head/contrib/telnet/telnet/commands.c Wed Jul 10 22:23:59 2019 (r349895) +++ head/contrib/telnet/telnet/commands.c Wed Jul 10 22:36:14 2019 (r349896) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include <sys/socket.h> #include <netinet/in.h> +#include <assert.h> #include <ctype.h> #include <err.h> #include <errno.h> @@ -1654,11 +1655,13 @@ 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'; - unsigned int buflen = strlen(hbuf) + strlen(cp2) + 1; + buflen = strlen(hbuf) + strlen(cp2) + 1; cp = (char *)malloc(sizeof(char)*buflen); + 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?201907102236.x6AMaFLI067550>