2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-08-31 06:15:55 +00:00

Hankin's fixes for hash-related core dumps on HEAD.

This commit is contained in:
Shane Kerr
2006-07-25 09:59:39 +00:00
parent dba5803b95
commit 272ef1bca0
3 changed files with 24 additions and 8 deletions

View File

@@ -34,7 +34,7 @@
#ifndef lint
static char copyright[] =
"$Id: parse.c,v 1.113 2006/07/22 02:24:16 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n";
"$Id: parse.c,v 1.114 2006/07/25 09:59:39 shane Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -991,7 +991,6 @@ parse_option_name (cfile, allocate, known, opt)
}
/* Look up the actual option info... */
option = (struct option *)0;
option_name_hash_lookup(opt, universe->name_hash, val, 0, MDL);
option = *opt;
@@ -1765,7 +1764,7 @@ int parse_executable_statement (result, cfile, lose, case_context)
const char *val;
struct executable_statement base;
struct class *cta;
struct option *option;
struct option *option=NULL;
struct option_cache *cache;
int known;
int flag;

View File

@@ -64,11 +64,13 @@ typedef int (*hash_comparator_t)(const void *, const void *, size_t);
struct hash_table {
unsigned hash_count;
struct hash_bucket *buckets [DEFAULT_HASH_SIZE];
hash_reference referencer;
hash_dereference dereferencer;
hash_comparator_t cmp;
unsigned (*do_hash)(const void *, unsigned, unsigned);
/* This must remain the last entry in this table. */
struct hash_bucket *buckets [1];
};
struct named_hash {

View File

@@ -34,7 +34,7 @@
#ifndef lint
static char copyright[] =
"$Id: hash.c,v 1.10 2006/06/08 23:51:37 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n";
"$Id: hash.c,v 1.11 2006/07/25 09:59:39 shane Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n";
#endif /* not lint */
#include <omapip/omapip_p.h>
@@ -62,6 +62,7 @@ int new_hash_table (tp, count, file, line)
int line;
{
struct hash_table *rval;
unsigned extra;
if (!tp) {
log_error ("%s(%d): new_hash_table called with null pointer.",
@@ -78,9 +79,18 @@ int new_hash_table (tp, count, file, line)
abort ();
#endif
}
rval = dmalloc (sizeof (struct hash_table) -
(DEFAULT_HASH_SIZE * sizeof (struct hash_bucket *)) +
(count * sizeof (struct hash_bucket *)), file, line);
/* There is one hash bucket in the structure. Allocate extra
* memory beyond the end of the structure to fulfill the requested
* count ("count - 1"). Do not let there be less than one.
*/
if (count <= 1)
extra = 0;
else
extra = count - 1;
rval = dmalloc(sizeof(struct hash_table) +
(extra * sizeof(struct hash_bucket *)), file, line);
if (!rval)
return 0;
rval -> hash_count = count;
@@ -386,6 +396,11 @@ int hash_lookup (vp, table, key, len, file, line)
if (!len)
len = find_length(key, table->do_hash);
if (*vp != NULL) {
log_fatal("Internal inconsistency: storage value has not been "
"initialized to zero (from %s:%d).", file, line);
}
hashno = (*table->do_hash)(key, len, table->hash_count);
for (bp = table -> buckets [hashno]; bp; bp = bp -> next) {