Created
July 11, 2019 14:56
-
-
Save lattera/14e4343b03e66ce934315d1589f86e71 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/contrib/telnet/telnet/commands.c b/contrib/telnet/telnet/commands.c | |
index c6dc4ca064b7..01a21302cc32 100644 | |
--- a/contrib/telnet/telnet/commands.c | |
+++ b/contrib/telnet/telnet/commands.c | |
@@ -1655,14 +1655,12 @@ 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); | |
+ cp = NULL; | |
+ 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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment