diff --git a/appl/telnet/telnet/commands.c b/appl/telnet/telnet/commands.c index 980abcd5c..1f8583481 100644 --- a/appl/telnet/telnet/commands.c +++ b/appl/telnet/telnet/commands.c @@ -1582,6 +1582,7 @@ env_init(void) || strncmp((char *)ep->value, "unix:", 5) == 0)) { char hbuf[256+1]; char *cp2 = strchr((char *)ep->value, ':'); + int error; /* XXX - should be k_gethostname? */ gethostname(hbuf, 256); @@ -1590,7 +1591,6 @@ env_init(void) /* If this is not the full name, try to get it via DNS */ if (strchr(hbuf, '.') == 0) { struct addrinfo hints, *ai, *a; - int error; memset (&hints, 0, sizeof(hints)); hints.ai_flags = AI_CANONNAME; @@ -1608,9 +1608,11 @@ env_init(void) } } - asprintf (&cp, "%s%s", hbuf, cp2); - free (ep->value); - ep->value = (unsigned char *)cp; + error = asprintf (&cp, "%s%s", hbuf, cp2); + if (error != -1) { + free (ep->value); + ep->value = (unsigned char *)cp; + } } /* * If USER is not defined, but LOGNAME is, then add diff --git a/appl/xnlock/xnlock.c b/appl/xnlock/xnlock.c index 3ba32abdd..b92f439f9 100644 --- a/appl/xnlock/xnlock.c +++ b/appl/xnlock/xnlock.c @@ -244,9 +244,10 @@ init_words (int argc, char **argv) appres.file = argv[i]; i++; } else { - asprintf (&appres.file, + int ret; + ret = asprintf (&appres.file, "%s/.msgfile", getenv("HOME")); - if (appres.file == NULL) + if (ret == -1) errx (1, "cannot allocate memory for message"); } } else if(strcmp(argv[i], "--version") == 0) {