diff options
author | Miles Bader <miles@gnu.org> | 1995-12-17 20:58:55 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 1995-12-17 20:58:55 +0000 |
commit | 5ca8c0ba635c9668e43a37b4706efa3e6a6b4c8b (patch) | |
tree | 8b3ac0f047e8bac7ecbcbeb46326c66662bc9009 | |
parent | 102800e09dd56055f0e1a6f6868bfa5ac87d9459 (diff) | |
download | glibc-5ca8c0ba635c9668e43a37b4706efa3e6a6b4c8b.tar glibc-5ca8c0ba635c9668e43a37b4706efa3e6a6b4c8b.tar.gz glibc-5ca8c0ba635c9668e43a37b4706efa3e6a6b4c8b.tar.bz2 glibc-5ca8c0ba635c9668e43a37b4706efa3e6a6b4c8b.zip |
(getpass): Don't barf if getline returns a null BUF.
-rw-r--r-- | misc/getpass.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/misc/getpass.c b/misc/getpass.c index bea2ac0d08..16f4a3a365 100644 --- a/misc/getpass.c +++ b/misc/getpass.c @@ -74,16 +74,17 @@ getpass (prompt) /* Read the password. */ nread = __getline (&buf, &bufsize, in); - if (nread < 0 && buf != NULL) - buf[0] = '\0'; - else if (buf[nread - 1] == '\n') - { - /* Remove the newline. */ - buf[nread - 1] = '\0'; - if (echo_off) - /* Write the newline that was not echoed. */ - putc ('\n', out); - } + if (buf != NULL) + if (nread < 0) + buf[0] = '\0'; + else if (buf[nread - 1] == '\n') + { + /* Remove the newline. */ + buf[nread - 1] = '\0'; + if (echo_off) + /* Write the newline that was not echoed. */ + putc ('\n', out); + } /* Restore echoing. */ if (echo_off) |