diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c index 66141cb30689..c78d20d53a75 100644 --- a/lib/libc/db/hash/hash.c +++ b/lib/libc/db/hash/hash.c @@ -1,4 +1,4 @@ -/* $NetBSD: hash.c,v 1.16 2002/01/12 11:26:13 aymeric Exp $ */ +/* $NetBSD: hash.c,v 1.17 2002/12/11 21:20:15 christos Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)hash.c 8.9 (Berkeley) 6/16/94"; #else -__RCSID("$NetBSD: hash.c,v 1.16 2002/01/12 11:26:13 aymeric Exp $"); +__RCSID("$NetBSD: hash.c,v 1.17 2002/12/11 21:20:15 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -312,7 +312,7 @@ init_hash(hashp, file, info) if (file != NULL) { if (stat(file, &statbuf)) return (NULL); - hashp->BSIZE = statbuf.st_blksize; + hashp->BSIZE = MIN(statbuf.st_blksize, MAX_BSIZE - 1); hashp->BSHIFT = __log2((u_int32_t)hashp->BSIZE); } @@ -321,7 +321,7 @@ init_hash(hashp, file, info) /* Round pagesize up to power of 2 */ hashp->BSHIFT = __log2(info->bsize); hashp->BSIZE = 1 << hashp->BSHIFT; - if (hashp->BSIZE > MAX_BSIZE) { + if (hashp->BSIZE >= MAX_BSIZE) { errno = EINVAL; return (NULL); }