summaryrefslogtreecommitdiffstats
path: root/lib/libutil
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>1997-11-17 21:12:12 +0000
committermillert <millert@openbsd.org>1997-11-17 21:12:12 +0000
commite77705349a05e9ff9692c2645ef8bfcb3bf7b9f6 (patch)
tree5729a5a5dc1b8889b78533aafcd07c64035fc896 /lib/libutil
parentWork around bug in open(2) wrt O_TRUNC and O_SHLOCK|O_EXLOCK. (diff)
downloadwireguard-openbsd-e77705349a05e9ff9692c2645ef8bfcb3bf7b9f6.tar.xz
wireguard-openbsd-e77705349a05e9ff9692c2645ef8bfcb3bf7b9f6.zip
pw_mkdb() now returns -1 if ptmp is size 0.
Diffstat (limited to 'lib/libutil')
-rw-r--r--lib/libutil/passwd.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/libutil/passwd.c b/lib/libutil/passwd.c
index 83c5c8d6614..b1128ae3994 100644
--- a/lib/libutil/passwd.c
+++ b/lib/libutil/passwd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: passwd.c,v 1.13 1997/11/17 20:56:57 millert Exp $ */
+/* $OpenBSD: passwd.c,v 1.14 1997/11/17 21:12:12 millert Exp $ */
/*
* Copyright (c) 1987, 1993, 1994, 1995
@@ -34,7 +34,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: passwd.c,v 1.13 1997/11/17 20:56:57 millert Exp $";
+static char rcsid[] = "$OpenBSD: passwd.c,v 1.14 1997/11/17 21:12:12 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -270,6 +270,15 @@ pw_mkdb()
int pstat;
pid_t pid;
char *lock;
+ struct stat sb;
+
+ /* A zero length passwd file is never ok */
+ if (pw_lck && stat(pw_lck, &sb) == 0) {
+ if (sb.st_size == 0) {
+ warnx("%s is zero length", pw_lck);
+ return (-1);
+ }
+ }
pid = vfork();
if (pid == 0) {