mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-09-03 07:45:20 +00:00
Hankin's fixes for hash-related core dumps on HEAD.
This commit is contained in:
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
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 */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "dhcpd.h"
|
#include "dhcpd.h"
|
||||||
@@ -991,7 +991,6 @@ parse_option_name (cfile, allocate, known, opt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Look up the actual option info... */
|
/* Look up the actual option info... */
|
||||||
option = (struct option *)0;
|
|
||||||
option_name_hash_lookup(opt, universe->name_hash, val, 0, MDL);
|
option_name_hash_lookup(opt, universe->name_hash, val, 0, MDL);
|
||||||
option = *opt;
|
option = *opt;
|
||||||
|
|
||||||
@@ -1765,7 +1764,7 @@ int parse_executable_statement (result, cfile, lose, case_context)
|
|||||||
const char *val;
|
const char *val;
|
||||||
struct executable_statement base;
|
struct executable_statement base;
|
||||||
struct class *cta;
|
struct class *cta;
|
||||||
struct option *option;
|
struct option *option=NULL;
|
||||||
struct option_cache *cache;
|
struct option_cache *cache;
|
||||||
int known;
|
int known;
|
||||||
int flag;
|
int flag;
|
||||||
|
@@ -64,11 +64,13 @@ typedef int (*hash_comparator_t)(const void *, const void *, size_t);
|
|||||||
|
|
||||||
struct hash_table {
|
struct hash_table {
|
||||||
unsigned hash_count;
|
unsigned hash_count;
|
||||||
struct hash_bucket *buckets [DEFAULT_HASH_SIZE];
|
|
||||||
hash_reference referencer;
|
hash_reference referencer;
|
||||||
hash_dereference dereferencer;
|
hash_dereference dereferencer;
|
||||||
hash_comparator_t cmp;
|
hash_comparator_t cmp;
|
||||||
unsigned (*do_hash)(const void *, unsigned, unsigned);
|
unsigned (*do_hash)(const void *, unsigned, unsigned);
|
||||||
|
|
||||||
|
/* This must remain the last entry in this table. */
|
||||||
|
struct hash_bucket *buckets [1];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct named_hash {
|
struct named_hash {
|
||||||
|
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
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 */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <omapip/omapip_p.h>
|
#include <omapip/omapip_p.h>
|
||||||
@@ -62,6 +62,7 @@ int new_hash_table (tp, count, file, line)
|
|||||||
int line;
|
int line;
|
||||||
{
|
{
|
||||||
struct hash_table *rval;
|
struct hash_table *rval;
|
||||||
|
unsigned extra;
|
||||||
|
|
||||||
if (!tp) {
|
if (!tp) {
|
||||||
log_error ("%s(%d): new_hash_table called with null pointer.",
|
log_error ("%s(%d): new_hash_table called with null pointer.",
|
||||||
@@ -78,9 +79,18 @@ int new_hash_table (tp, count, file, line)
|
|||||||
abort ();
|
abort ();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
rval = dmalloc (sizeof (struct hash_table) -
|
|
||||||
(DEFAULT_HASH_SIZE * sizeof (struct hash_bucket *)) +
|
/* There is one hash bucket in the structure. Allocate extra
|
||||||
(count * sizeof (struct hash_bucket *)), file, line);
|
* 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)
|
if (!rval)
|
||||||
return 0;
|
return 0;
|
||||||
rval -> hash_count = count;
|
rval -> hash_count = count;
|
||||||
@@ -386,6 +396,11 @@ int hash_lookup (vp, table, key, len, file, line)
|
|||||||
if (!len)
|
if (!len)
|
||||||
len = find_length(key, table->do_hash);
|
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);
|
hashno = (*table->do_hash)(key, len, table->hash_count);
|
||||||
|
|
||||||
for (bp = table -> buckets [hashno]; bp; bp = bp -> next) {
|
for (bp = table -> buckets [hashno]; bp; bp = bp -> next) {
|
||||||
|
Reference in New Issue
Block a user