summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2012-01-17 17:02:34 +0100
committerKarel Zak2012-01-17 17:02:34 +0100
commitaa1f95c3d0e729a37bfb4a9befb1904e81e46ea5 (patch)
treef302e6ca7d601515c8070b856f37bf27b729858e
parentdmesg: fix non-ANSI function declaration [smatch scan] (diff)
downloadkernel-qcow2-util-linux-aa1f95c3d0e729a37bfb4a9befb1904e81e46ea5.tar.gz
kernel-qcow2-util-linux-aa1f95c3d0e729a37bfb4a9befb1904e81e46ea5.tar.xz
kernel-qcow2-util-linux-aa1f95c3d0e729a37bfb4a9befb1904e81e46ea5.zip
losetup: make xgetpass more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--include/c.h1
-rw-r--r--lib/xgetpass.c4
2 files changed, 3 insertions, 2 deletions
diff --git a/include/c.h b/include/c.h
index 073615ef3..b6d8cedaf 100644
--- a/include/c.h
+++ b/include/c.h
@@ -6,6 +6,7 @@
#define UTIL_LINUX_C_H
#include <limits.h>
+#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdarg.h>
diff --git a/lib/xgetpass.c b/lib/xgetpass.c
index 858768148..ba2089470 100644
--- a/lib/xgetpass.c
+++ b/lib/xgetpass.c
@@ -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;
}