telnet: fix minor style violation
While here also fix a very unlikely NULL pointer dereference. Submitted by: Shawn Webb <shawn.webb@hardenedbsd.org>
This commit is contained in:
parent
f6ccd325fc
commit
6071f00ffe
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user