summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorTed Lemon <source@isc.org>1996-08-27 09:49:53 +0000
committerTed Lemon <source@isc.org>1996-08-27 09:49:53 +0000
commit370983c3022a1a1582d36a069df0c4e6d1478f78 (patch)
tree4d1c9fb5548d8b4b88c37c73546911bc88734171 /common
parentf8b7d0973ffa21af1e9c85049e3d487bb108bfa9 (diff)
downloadisc-dhcp-370983c3022a1a1582d36a069df0c4e6d1478f78.tar.gz
Make copies of hash table keys (not sure this is right).
Diffstat (limited to 'common')
-rw-r--r--common/hash.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/common/hash.c b/common/hash.c
index 68972b72..ccff48ea 100644
--- a/common/hash.c
+++ b/common/hash.c
@@ -42,7 +42,7 @@
#ifndef lint
static char copyright[] =
-"@(#) Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: hash.c,v 1.7 1996/08/27 09:49:53 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -108,7 +108,15 @@ void add_hash (table, name, len, pointer)
warn ("Can't add %s to hash table.", name);
return;
}
- bp -> name = name;
+ bp -> name = malloc (len ? len : strlen (name) + 1);
+ if (!bp -> name) {
+ warn ("Can't add %s to hash table.", name);
+ free_hash_bucket (bp, "add_hash");
+ }
+ if (len)
+ memcpy (bp -> name, name, len);
+ else
+ strcpy (bp -> name, name);
bp -> value = pointer;
bp -> next = table -> buckets [hashno];
bp -> len = len;