]> diplodocus.org Git - nmh/commit
getpass.c: Don't fileno(NULL) when fopen("/dev/tty") fails.
authorRalph Corderoy <ralph@inputplus.co.uk>
Thu, 7 Sep 2017 09:16:36 +0000 (10:16 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Thu, 7 Sep 2017 09:47:25 +0000 (10:47 +0100)
commitda05b66b6d580781850f10122f720b8771a739f7
tree1f02d28e95e22af7c0d654860bbca9939e371f63
parented4e21fb32d214ed9c45d0bd4eac9d3dd8ee6c9d
getpass.c: Don't fileno(NULL) when fopen("/dev/tty") fails.

If stdin is a TTY, but opening it for writing fails, then stdin and
stderr are used as defaults and the TTY doesn't have echo disabled.  The
later test to restore echo just checks if stdin is a TTY and not that it
was opened successfully causing a NULL FILE pointer to be fileno(3)'d.
Fixes da6af9633.  This function's logic remains a bit contorted;  I went
for the minimal fix.
sbr/getpass.c