Check the return value of fgets
authorVolker Lendecke <vl@samba.org>
Sat, 23 Feb 2008 09:42:43 +0000 (10:42 +0100)
committerStefan Metzmacher <metze@samba.org>
Tue, 18 Mar 2008 15:40:46 +0000 (16:40 +0100)
(cherry picked from commit b8aaa9a69fd6217ce0387ef8e84f316706186d70)
(This used to be commit 8f58d39c0c621e9da85308d721a146352cc4939e)

source4/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) {