Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/cdb Don't refuse the open databases without entries...
details: https://anonhg.NetBSD.org/src/rev/81998801d4bb
branches: trunk
changeset: 781738:81998801d4bb
user: joerg <joerg%NetBSD.org@localhost>
date: Thu Sep 27 00:37:43 2012 +0000
description:
Don't refuse the open databases without entries or keys, just protect
the divisions. cdbr_find and cdbr_get already have the appropiate
checks.
diffstat:
lib/libc/cdb/cdbr.c | 20 ++++++++++++--------
1 files changed, 12 insertions(+), 8 deletions(-)
diffs (46 lines):
diff -r 80c05c683928 -r 81998801d4bb lib/libc/cdb/cdbr.c
--- a/lib/libc/cdb/cdbr.c Thu Sep 27 00:25:26 2012 +0000
+++ b/lib/libc/cdb/cdbr.c Thu Sep 27 00:37:43 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cdbr.c,v 1.3 2012/06/04 19:06:45 joerg Exp $ */
+/* $NetBSD: cdbr.c,v 1.4 2012/09/27 00:37:43 joerg Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -36,7 +36,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: cdbr.c,v 1.3 2012/06/04 19:06:45 joerg Exp $");
+__RCSID("$NetBSD: cdbr.c,v 1.4 2012/09/27 00:37:43 joerg Exp $");
#include "namespace.h"
@@ -152,17 +152,21 @@
cdbr->data_base < cdbr->mmap_base ||
cdbr->data_base + cdbr->data_size < cdbr->mmap_base ||
cdbr->data_base + cdbr->data_size >
- cdbr->mmap_base + cdbr->mmap_size ||
- cdbr->entries == 0 || cdbr->entries_index == 0) {
+ cdbr->mmap_base + cdbr->mmap_size) {
errno = EINVAL;
cdbr_close(cdbr);
return NULL;
}
- fast_divide32_prepare(cdbr->entries, &cdbr->entries_m,
- &cdbr->entries_s1, &cdbr->entries_s2);
- fast_divide32_prepare(cdbr->entries_index, &cdbr->entries_index_m,
- &cdbr->entries_index_s1, &cdbr->entries_index_s2);
+ if (cdbr->entries) {
+ fast_divide32_prepare(cdbr->entries, &cdbr->entries_m,
+ &cdbr->entries_s1, &cdbr->entries_s2);
+ }
+ if (cdbr->entries_index) {
+ fast_divide32_prepare(cdbr->entries_index,
+ &cdbr->entries_index_m,
+ &cdbr->entries_index_s1, &cdbr->entries_index_s2);
+ }
return cdbr;
}
Home |
Main Index |
Thread Index |
Old Index