OSDN Git Service

patch from ashwini sharma: treat 0 length read at the start of password read as EOF.
authorRob Landley <rob@landley.net>
Sat, 24 May 2014 17:48:32 +0000 (12:48 -0500)
committerRob Landley <rob@landley.net>
Sat, 24 May 2014 17:48:32 +0000 (12:48 -0500)
lib/password.c

index 13a431a..930e9c3 100644 (file)
@@ -79,7 +79,7 @@ int read_password(char * buff, int buflen, char* mesg)
 
   while (1) {
     int ret = read(0, &buff[i], 1);
-    if ( ret < 0 ) {
+    if ( ret < 0 || (!ret && !i)) {
       buff[0] = 0;
       sigaction(SIGINT, &oldsa, NULL);
       tcsetattr(0, TCSANOW, &oldtermio);