Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-6]: src/lib/libc/cdb Pull up following revision(s) (requested by ...



details:   https://anonhg.NetBSD.org/src/rev/dee4f7bc6e75
branches:  netbsd-6
changeset: 775354:dee4f7bc6e75
user:      riz <riz%NetBSD.org@localhost>
date:      Wed Oct 17 21:39:17 2012 +0000

description:
Pull up following revision(s) (requested by joerg in ticket #577):
        lib/libc/cdb/cdbr.c: revision 1.4
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 afa92578c064 -r dee4f7bc6e75 lib/libc/cdb/cdbr.c
--- a/lib/libc/cdb/cdbr.c       Wed Oct 17 21:37:11 2012 +0000
+++ b/lib/libc/cdb/cdbr.c       Wed Oct 17 21:39:17 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cdbr.c,v 1.2.8.1 2012/06/23 22:54:58 riz Exp $ */
+/*     $NetBSD: cdbr.c,v 1.2.8.2 2012/10/17 21:39:17 riz 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.2.8.1 2012/06/23 22:54:58 riz Exp $");
+__RCSID("$NetBSD: cdbr.c,v 1.2.8.2 2012/10/17 21:39:17 riz 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