diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2000-08-01 21:26:11 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2000-08-01 21:26:11 +0000 |
commit | 72e3a9f626e20354527aad68a8533df3643a5a17 (patch) | |
tree | d528251184ec0628448542add13c955d41a82806 /lib/libc | |
parent | d58440b157a9e204ba77fcbcea102cf00b721198 (diff) |
Traditional NDBM supports dbm_open(foo, O_WRONLY) but dbopen() does
not allow O_WRONLY (it returns EINVAL). If the users passes O_WRONLY
to dbm_open, strip it and use O_RDWR instead.
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/db/hash/ndbm.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/libc/db/hash/ndbm.c b/lib/libc/db/hash/ndbm.c index 2d54848ad78..73e9274b440 100644 --- a/lib/libc/db/hash/ndbm.c +++ b/lib/libc/db/hash/ndbm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ndbm.c,v 1.11 1999/04/18 17:08:07 millert Exp $ */ +/* $OpenBSD: ndbm.c,v 1.12 2000/08/01 21:26:10 millert Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -40,7 +40,7 @@ #if 0 static char sccsid[] = "@(#)dbm.c 8.6 (Berkeley) 11/7/95"; #else -static char rcsid[] = "$OpenBSD: ndbm.c,v 1.11 1999/04/18 17:08:07 millert Exp $"; +static char rcsid[] = "$OpenBSD: ndbm.c,v 1.12 2000/08/01 21:26:10 millert Exp $"; #endif #endif /* LIBC_SCCS and not lint */ @@ -204,6 +204,11 @@ _dbm_open(file, suff, flags, mode) errno = ENAMETOOLONG; return (NULL); } + /* O_WRONLY not supported by db(3) but traditional ndbm allowed it. */ + if ((flags & O_ACCMODE) == O_WRONLY) { + flags &= ~O_WRONLY; + flags |= O_RDWR; + } info.bsize = 4096; info.ffactor = 40; info.nelem = 1; |