summaryrefslogtreecommitdiffhomepage
path: root/src/dhcpv4.c
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2019-05-14 16:18:51 +0200
committerHans Dedecker <dedeckeh@gmail.com>2019-05-15 10:10:08 +0200
commitc0c8034bc17519c7960f40f6d796b5485cfc4cdb (patch)
treeef3079b303164e2c5313a89e97e4d8e4d6aed4b1 /src/dhcpv4.c
parentf98b7ee899d492d32c4d857aa068daf95ae5be7b (diff)
treewide: init assignment lists head
When allocating an assignment in alloc_assignment; init the circular head and lease_list circular lists. Avoids checking NULL pointer when freeing the assignment in free_assignment. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'src/dhcpv4.c')
-rw-r--r--src/dhcpv4.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/dhcpv4.c b/src/dhcpv4.c
index 9d21423..2634f65 100644
--- a/src/dhcpv4.c
+++ b/src/dhcpv4.c
@@ -1024,9 +1024,9 @@ dhcpv4_lease(struct interface *iface, enum dhcpv4_msg msg, const uint8_t *mac,
if (!a) {
if (!iface->no_dynamic_dhcp || l) {
/* Create new binding */
- a = calloc(1, sizeof(*a));
+ a = alloc_assignment(0);
if (!a) {
- syslog(LOG_ERR, "Failed to calloc binding on interface %s",
+ syslog(LOG_ERR, "Failed to alloc assignment on interface %s",
iface->ifname);
return NULL;
}
@@ -1057,7 +1057,7 @@ dhcpv4_lease(struct interface *iface, enum dhcpv4_msg msg, const uint8_t *mac,
} else if (((a->addr & iface->dhcpv4_mask.s_addr) !=
(iface->dhcpv4_start_ip.s_addr & iface->dhcpv4_mask.s_addr)) &&
!(a->flags & OAF_STATIC)) {
- list_del(&a->head);
+ list_del_init(&a->head);
a->addr = INADDR_ANY;
assigned = dhcpv4_assign(iface, a, reqaddr);