2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-09-01 23:05:17 +00:00

Don't set the tty variable to NULL when we lack a tty, leave it as

"unknown".
This commit is contained in:
Todd C. Miller
1997-12-21 23:17:48 +00:00
parent 687434bc96
commit 07e09b16f2

8
sudo.c
View File

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