]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
losetup: make xgetpass more robust
authorKarel Zak <kzak@redhat.com>
Tue, 17 Jan 2012 16:02:34 +0000 (17:02 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 17 Jan 2012 16:02:34 +0000 (17:02 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
include/c.h
lib/xgetpass.c

index 073615ef3e63acb452105f6134b4b94c5281c914..b6d8cedafa2a0ce43f15a51c150c54523834988c 100644 (file)
@@ -6,6 +6,7 @@
 #define UTIL_LINUX_C_H
 
 #include <limits.h>
+#include <stddef.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdarg.h>
index 8587681489c93d06d9d86acf97ded22e756f0f19..ba2089470c76b018bb4abb41afd5b8b7ccc80dfc 100644 (file)
@@ -34,8 +34,8 @@ char *xgetpass(int pfd, const char *prompt)
                                break;
                        }
                }
-               if (read(pfd, pass + i, 1) != 1 ||
-                   pass[i] == '\n' || pass[i] == 0)
+               if (pass && (read(pfd, pass + i, 1) != 1 ||
+                            pass[i] == '\n' || pass[i] == 0))
                        break;
        }