aboutsummaryrefslogtreecommitdiff
path: root/nscd/mem.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2006-10-02 16:34:25 +0000
committerUlrich Drepper <drepper@redhat.com>2006-10-02 16:34:25 +0000
commit0b25a49a94f6d125456f1f3ac70ca7b330b69eda (patch)
tree8f771fa4395563fce64c1b4eff22a5649fb7c6fa /nscd/mem.c
parenta128674505078487ccd21b1af49734ea7feb769a (diff)
downloadglibc-0b25a49a94f6d125456f1f3ac70ca7b330b69eda.tar
glibc-0b25a49a94f6d125456f1f3ac70ca7b330b69eda.tar.gz
glibc-0b25a49a94f6d125456f1f3ac70ca7b330b69eda.tar.bz2
glibc-0b25a49a94f6d125456f1f3ac70ca7b330b69eda.zip
* nscd/mem.c (mempool_alloc): Round array size to 16 bytes
in oldtotal and newtotal calculation. * nscd/nscd-client.h (struct mapped_database): Add datasize field. * nscd/nscd_helper.c (get_mapping): Initialize datasize field. (__nscd_get_map_ref): Get a new mapping even if mapping's data_size increased. (__nscd_cache_search): Add checks to make sure we never reference data beyond the current mapping.
Diffstat (limited to 'nscd/mem.c')
-rw-r--r--nscd/mem.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/nscd/mem.c b/nscd/mem.c
index a41c0bdb07..5206c5af38 100644
--- a/nscd/mem.c
+++ b/nscd/mem.c
@@ -1,5 +1,5 @@
/* Cache memory handling.
- Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
@@ -480,12 +480,12 @@ mempool_alloc (struct database_dyn *db, size_t len)
{
/* Try to resize the database. Grow size of 1/8th. */
size_t oldtotal = (sizeof (struct database_pers_head)
- + db->head->module * sizeof (ref_t)
+ + roundup (db->head->module * sizeof (ref_t), ALIGN)
+ db->head->data_size);
size_t new_data_size = (db->head->data_size
+ MAX (2 * len, db->head->data_size / 8));
size_t newtotal = (sizeof (struct database_pers_head)
- + db->head->module * sizeof (ref_t)
+ + roundup (db->head->module * sizeof (ref_t), ALIGN)
+ new_data_size);
if (newtotal > db->max_db_size)
{