(getpass): Don't barf if getline returns a null BUF.
This commit is contained in:
parent
102800e09d
commit
5ca8c0ba63
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue