Check the return value of fgets
authorVolker Lendecke <vl@samba.org>
Sat, 23 Feb 2008 09:42:43 +0000 (10:42 +0100)
committerVolker Lendecke <vl@samba.org>
Sat, 23 Feb 2008 10:04:13 +0000 (11:04 +0100)
(This used to be commit b8aaa9a69fd6217ce0387ef8e84f316706186d70)

source3/lib/replace/getpass.c

index d91d029f6a79ced4089af86cb0b4d0a97b77b608..57e28eb981577594c2d8b6a0511fe2a21157f9ec 100644 (file)
@@ -185,7 +185,10 @@ char *rep_getpass(const char *prompt)
        buf[0] = 0;
        if (!gotintr) {
                in_fd = fileno(in);
-               fgets(buf, bufsize, in);
+               if (fgets(buf, bufsize, in) == NULL) {
+                       buf[0] = 0;
+                       return buf;
+               }
        }
        nread = strlen(buf);
        if (nread) {