summaryrefslogtreecommitdiff
path: root/lib/libc/db
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2001-01-03 15:24:10 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2001-01-03 15:24:10 +0000
commit1fc55dfbde4a8de5d2139db13d4cef0f0689c4d3 (patch)
treeecb27a54a9ad4d75a98d44b75e0696af9ff4c176 /lib/libc/db
parenteea56a8328695aadb696c29d306651aebc83647e (diff)
Make it an error to open a zero-length file for read-only access.
This makes cap_mkdb happier, though cap_mkdb still behaves incorrectly when given multiple files (but that is cap_mkdb's fault).
Diffstat (limited to 'lib/libc/db')
-rw-r--r--lib/libc/db/hash/hash.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c
index f3635ed7772..cd550fd06a3 100644
--- a/lib/libc/db/hash/hash.c
+++ b/lib/libc/db/hash/hash.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hash.c,v 1.8 1999/04/18 17:08:07 millert Exp $ */
+/* $OpenBSD: hash.c,v 1.9 2001/01/03 15:24:09 millert Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@@ -40,7 +40,7 @@
#if 0
static char sccsid[] = "@(#)hash.c 8.9 (Berkeley) 6/16/94";
#else
-static char rcsid[] = "$OpenBSD: hash.c,v 1.8 1999/04/18 17:08:07 millert Exp $";
+static char rcsid[] = "$OpenBSD: hash.c,v 1.9 2001/01/03 15:24:09 millert Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -130,7 +130,7 @@ __hash_open(file, flags, mode, info, dflags)
new_table = 0;
if (!file || (flags & O_TRUNC) ||
((rv = stat(file, &statbuf)) && errno == ENOENT) ||
- (rv == 0 && statbuf.st_size == 0)) {
+ (rv == 0 && !statbuf.st_size && (flags & O_ACCMODE) != O_RDONLY)) {
if (errno == ENOENT)
errno = 0; /* Just in case someone looks at errno */
new_table = 1;