summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;
}