summaryrefslogtreecommitdiff
path: root/libc/unistd/getpass.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/unistd/getpass.c')
-rw-r--r--libc/unistd/getpass.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libc/unistd/getpass.c b/libc/unistd/getpass.c
index 4fcc489c8..92d3565c8 100644
--- a/libc/unistd/getpass.c
+++ b/libc/unistd/getpass.c
@@ -17,6 +17,7 @@
Boston, MA 02111-1307, USA. */
#include <stdio.h>
+#include <string.h>
#include <termios.h>
#include <unistd.h>
#include <string.h>
@@ -72,9 +73,9 @@ getpass (prompt)
/* Read the password. */
fgets (buf, PWD_BUFFER_SIZE-1, in);
- nread = strlen(buf);
if (buf != NULL)
{
+ nread = strlen(buf);
if (nread < 0)
buf[0] = '\0';
else if (buf[nread - 1] == '\n')