diff options
Diffstat (limited to 'lib/libc/db/hash')
-rw-r--r-- | lib/libc/db/hash/Makefile.inc | 3 | ||||
-rw-r--r-- | lib/libc/db/hash/README | 2 | ||||
-rw-r--r-- | lib/libc/db/hash/extern.h | 3 | ||||
-rw-r--r-- | lib/libc/db/hash/hash.c | 30 | ||||
-rw-r--r-- | lib/libc/db/hash/hash.h | 3 | ||||
-rw-r--r-- | lib/libc/db/hash/hash_bigkey.c | 6 | ||||
-rw-r--r-- | lib/libc/db/hash/hash_buf.c | 6 | ||||
-rw-r--r-- | lib/libc/db/hash/hash_func.c | 6 | ||||
-rw-r--r-- | lib/libc/db/hash/hash_log2.c | 6 | ||||
-rw-r--r-- | lib/libc/db/hash/hash_page.c | 11 | ||||
-rw-r--r-- | lib/libc/db/hash/ndbm.c | 6 | ||||
-rw-r--r-- | lib/libc/db/hash/page.h | 3 |
12 files changed, 17 insertions, 68 deletions
diff --git a/lib/libc/db/hash/Makefile.inc b/lib/libc/db/hash/Makefile.inc index e1be7a565a2c..0d58e60796a1 100644 --- a/lib/libc/db/hash/Makefile.inc +++ b/lib/libc/db/hash/Makefile.inc @@ -1,6 +1,3 @@ -# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 -# $FreeBSD$ - .PATH: ${LIBC_SRCTOP}/db/hash SRCS+= hash.c hash_bigkey.c hash_buf.c hash_func.c hash_log2.c \ diff --git a/lib/libc/db/hash/README b/lib/libc/db/hash/README index 80d674396c0a..0a5a8142e896 100644 --- a/lib/libc/db/hash/README +++ b/lib/libc/db/hash/README @@ -1,5 +1,3 @@ -# @(#)README 8.1 (Berkeley) 6/4/93 -# $FreeBSD$ This package implements a superset of the hsearch and dbm/ndbm libraries. diff --git a/lib/libc/db/hash/extern.h b/lib/libc/db/hash/extern.h index e938f9123914..d3850752ad3a 100644 --- a/lib/libc/db/hash/extern.h +++ b/lib/libc/db/hash/extern.h @@ -27,9 +27,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)extern.h 8.4 (Berkeley) 6/16/94 - * $FreeBSD$ */ BUFHEAD *__add_ovflpage(HTAB *, BUFHEAD *); diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c index ebb8790b3f23..88a3ffeab828 100644 --- a/lib/libc/db/hash/hash.c +++ b/lib/libc/db/hash/hash.c @@ -32,12 +32,6 @@ * SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)hash.c 8.9 (Berkeley) 6/16/94"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include "namespace.h" #include <sys/param.h> #include <sys/stat.h> @@ -105,11 +99,6 @@ __hash_open(const char *file, int flags, int mode, DB *dbp; int bpages, hdrsize, new_table, nsegs, save_errno; - if ((flags & O_ACCMODE) == O_WRONLY) { - errno = EINVAL; - return (NULL); - } - if (!(hashp = (HTAB *)calloc(1, sizeof(HTAB)))) return (NULL); hashp->fp = -1; @@ -121,12 +110,17 @@ __hash_open(const char *file, int flags, int mode, * we can check accesses. */ hashp->flags = flags; + if ((flags & O_ACCMODE) == O_WRONLY) { + flags &= ~O_WRONLY; + flags |= O_RDWR; + } if (file) { if ((hashp->fp = _open(file, flags | O_CLOEXEC, mode)) == -1) RETURN_ERROR(errno, error0); new_table = _fstat(hashp->fp, &statbuf) == 0 && - statbuf.st_size == 0 && (flags & O_ACCMODE) != O_RDONLY; + statbuf.st_size == 0 && + ((flags & O_ACCMODE) != O_RDONLY || (flags & O_CREAT) != 0); } else new_table = 1; @@ -185,7 +179,7 @@ __hash_open(const char *file, int flags, int mode, __buf_init(hashp, DEF_BUFSIZE); hashp->new_file = new_table; - hashp->save_file = file && (hashp->flags & O_RDWR); + hashp->save_file = file && (flags & O_RDWR); hashp->cbucket = -1; if (!(dbp = (DB *)malloc(sizeof(DB)))) { save_errno = errno; @@ -529,6 +523,10 @@ hash_get(const DB *dbp, const DBT *key, DBT *data, u_int32_t flag) hashp->error = errno = EINVAL; return (ERROR); } + if ((hashp->flags & O_ACCMODE) == O_WRONLY) { + hashp->error = errno = EPERM; + return (ERROR); + } return (hash_access(hashp, HASH_GET, (DBT *)key, data)); } @@ -706,17 +704,19 @@ hash_seq(const DB *dbp, DBT *key, DBT *data, u_int32_t flag) u_int16_t *bp, ndx; hashp = (HTAB *)dbp->internal; - if (flag && flag != R_FIRST && flag != R_NEXT) { + if (flag != R_FIRST && flag != R_NEXT) { hashp->error = errno = EINVAL; return (ERROR); } #ifdef HASH_STATISTICS hash_accesses++; #endif - if ((hashp->cbucket < 0) || (flag == R_FIRST)) { + if (flag == R_FIRST) { hashp->cbucket = 0; hashp->cndx = 1; hashp->cpage = NULL; + } else if (hashp->cbucket < 0) { /* R_NEXT */ + return (ABNORMAL); } next_bucket: for (bp = NULL; !bp || !bp[0]; ) { diff --git a/lib/libc/db/hash/hash.h b/lib/libc/db/hash/hash.h index 5d4f8d5e8735..91d2a459bed2 100644 --- a/lib/libc/db/hash/hash.h +++ b/lib/libc/db/hash/hash.h @@ -30,9 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)hash.h 8.3 (Berkeley) 5/31/94 - * $FreeBSD$ */ /* Operations */ diff --git a/lib/libc/db/hash/hash_bigkey.c b/lib/libc/db/hash/hash_bigkey.c index 24596cf780ea..15fc0899e27e 100644 --- a/lib/libc/db/hash/hash_bigkey.c +++ b/lib/libc/db/hash/hash_bigkey.c @@ -32,12 +32,6 @@ * SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)hash_bigkey.c 8.3 (Berkeley) 5/31/94"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * PACKAGE: hash * DESCRIPTION: diff --git a/lib/libc/db/hash/hash_buf.c b/lib/libc/db/hash/hash_buf.c index 63cc9eb4d9ad..94f95c8c0383 100644 --- a/lib/libc/db/hash/hash_buf.c +++ b/lib/libc/db/hash/hash_buf.c @@ -32,12 +32,6 @@ * SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)hash_buf.c 8.5 (Berkeley) 7/15/94"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * PACKAGE: hash * diff --git a/lib/libc/db/hash/hash_func.c b/lib/libc/db/hash/hash_func.c index 988e0eed2a30..529180b7698d 100644 --- a/lib/libc/db/hash/hash_func.c +++ b/lib/libc/db/hash/hash_func.c @@ -32,12 +32,6 @@ * SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)hash_func.c 8.2 (Berkeley) 2/21/94"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <db.h> diff --git a/lib/libc/db/hash/hash_log2.c b/lib/libc/db/hash/hash_log2.c index d89351cb415f..035b073e5d52 100644 --- a/lib/libc/db/hash/hash_log2.c +++ b/lib/libc/db/hash/hash_log2.c @@ -32,12 +32,6 @@ * SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)hash_log2.c 8.2 (Berkeley) 5/31/94"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <db.h> #include "hash.h" #include "page.h" diff --git a/lib/libc/db/hash/hash_page.c b/lib/libc/db/hash/hash_page.c index fba854b51f33..2a7b594dc3ea 100644 --- a/lib/libc/db/hash/hash_page.c +++ b/lib/libc/db/hash/hash_page.c @@ -32,12 +32,6 @@ * SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)hash_page.c 8.7 (Berkeley) 8/16/94"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * PACKAGE: hashing * @@ -855,11 +849,10 @@ open_temp(HTAB *hashp) { sigset_t set, oset; int len; - char *envtmp = NULL; + char *envtmp; char path[MAXPATHLEN]; - if (issetugid() == 0) - envtmp = getenv("TMPDIR"); + envtmp = secure_getenv("TMPDIR"); len = snprintf(path, sizeof(path), "%s/_hash.XXXXXX", envtmp ? envtmp : "/tmp"); if (len < 0 || len >= (int)sizeof(path)) { diff --git a/lib/libc/db/hash/ndbm.c b/lib/libc/db/hash/ndbm.c index ace1fb8b9fa7..b9d663a2de4c 100644 --- a/lib/libc/db/hash/ndbm.c +++ b/lib/libc/db/hash/ndbm.c @@ -32,12 +32,6 @@ * SUCH DAMAGE. */ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)ndbm.c 8.4 (Berkeley) 7/21/94"; -#endif /* LIBC_SCCS and not lint */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - /* * This package provides a dbm compatible interface to the new hashing * package described in db(3). diff --git a/lib/libc/db/hash/page.h b/lib/libc/db/hash/page.h index 17070e1ff584..372669a5e6d4 100644 --- a/lib/libc/db/hash/page.h +++ b/lib/libc/db/hash/page.h @@ -30,9 +30,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)page.h 8.2 (Berkeley) 5/31/94 - * $FreeBSD$ */ /* |