]> granicus.if.org Git - sudo/commitdiff
Don't set the tty variable to NULL when we lack a tty, leave it as
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 21 Dec 1997 23:17:48 +0000 (23:17 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 21 Dec 1997 23:17:48 +0000 (23:17 +0000)
"unknown".

sudo.c

diff --git a/sudo.c b/sudo.c
index 8342ce59f2537a519bf14ca3c6dc1c582194d2e4..bfad70a591a90d134c99e8545aa36231e0375da5 100644 (file)
--- a/sudo.c
+++ b/sudo.c
@@ -433,10 +433,10 @@ static void load_globals(sudo_mode)
     /*
      * Need to get tty early since it's used for logging
      */
-    if ((tty = (char *) ttyname(0)) || (tty = (char *) ttyname(1))) {
-       if (strncmp(tty, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
-           tty += sizeof(_PATH_DEV) - 1;
-       if ((tty = (char *) strdup(tty)) == NULL) {
+    if ((p = (char *) ttyname(0)) || (p = (char *) ttyname(1))) {
+       if (strncmp(p, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
+           p += sizeof(_PATH_DEV) - 1;
+       if ((tty = (char *) strdup(p)) == NULL) {
            perror("malloc");
            (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
            exit(1);