Only allow BSIZE to 1^16 - 1:

- fix off by one error
    - limit the default from the filesystem
This commit is contained in:
christos 2002-12-11 21:20:15 +00:00
parent 0c7b52a284
commit 14c54c3327
1 changed files with 4 additions and 4 deletions

View File

@ -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);
}