From: Hans Dedecker Date: Mon, 18 Feb 2019 13:11:12 +0000 (+0100) Subject: dhcpv4: fix assignment of requested IP address X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=67b3a141da8bbfd9fc506d043f1e7e1a92e2c7f9;p=oweals%2Fodhcpd.git dhcpv4: fix assignment of requested IP address Fix assignment of requested IP address by a client in case the assignment list is empty. Signed-off-by: Hans Dedecker --- diff --git a/src/dhcpv4.c b/src/dhcpv4.c index da2c051..252003b 100644 --- a/src/dhcpv4.c +++ b/src/dhcpv4.c @@ -920,9 +920,15 @@ static bool dhcpv4_assign(struct interface *iface, struct dhcp_assignment *a, /* try to assign the IP the client asked for */ if (start <= ntohl(raddr) && ntohl(raddr) <= end && !config_find_lease_by_ipaddr(raddr)) { + if (list_empty(&iface->dhcpv4_assignments)) { + list_add(&a->head, &iface->dhcpv4_assignments); + goto raddr_out; + } + list_for_each_entry(c, &iface->dhcpv4_assignments, head) { if (ntohl(c->addr) > ntohl(raddr)) { list_add_tail(&a->head, &c->head); +raddr_out: a->addr = raddr; syslog(LOG_INFO, "Assigning the IP the client asked for: %u.%u.%u.%u",