From fa9b094891049a0cdb6c6379e8308cb3a07614ef Mon Sep 17 00:00:00 2001 From: Seonah Moon Date: Fri, 15 Jun 2018 14:33:36 +0900 Subject: [PATCH] Fix crash issue SIGBUS crash has occured when ipv6 address is copied. Change-Id: Ie58721f2f8aa909c61d97c7640f0897bfdb5383e --- src/lease.c | 19 ++++++++++++++++--- src/rfc3315.c | 2 ++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/lease.c b/src/lease.c index 5c33df7..64f6647 100644 --- a/src/lease.c +++ b/src/lease.c @@ -687,16 +687,21 @@ struct dhcp_lease *lease6_find_by_client(struct dhcp_lease *first, int lease_typ struct dhcp_lease *lease6_find_by_addr(struct in6_addr *net, int prefix, u64 addr) { struct dhcp_lease *lease; - + + my_syslog(MS_DHCP | LOG_INFO, "lease6_find_by_addr(): +"); + for (lease = leases; lease; lease = lease->next) { if (!(lease->flags & (LEASE_TA | LEASE_NA))) continue; if (is_same_net6(&lease->addr6, net, prefix) && - (prefix == 128 || addr6part(&lease->addr6) == addr)) + (prefix == 128 || addr6part(&lease->addr6) == addr)) { + my_syslog(MS_DHCP | LOG_INFO, "lease6_find_by_addr(): -"); return lease; + } } + my_syslog(MS_DHCP | LOG_INFO, "lease6_find_by_addr(): -"); return NULL; } @@ -750,6 +755,9 @@ struct in_addr lease_find_max_addr(struct dhcp_context *context) static struct dhcp_lease *lease_allocate(void) { struct dhcp_lease *lease; + + my_syslog(MS_DHCP | LOG_INFO, "lease_allocate(): +"); + if (!leases_left || !(lease = whine_malloc(sizeof(struct dhcp_lease)))) return NULL; @@ -766,6 +774,8 @@ static struct dhcp_lease *lease_allocate(void) file_dirty = 1; leases_left--; + my_syslog(MS_DHCP | LOG_INFO, "lease_allocate(): -"); + return lease; } @@ -781,15 +791,18 @@ struct dhcp_lease *lease4_allocate(struct in_addr addr) #ifdef HAVE_DHCP6 struct dhcp_lease *lease6_allocate(struct in6_addr *addrp, int lease_type) { + my_syslog(MS_DHCP | LOG_INFO, "lease6_allocate(): +"); + struct dhcp_lease *lease = lease_allocate(); if (lease) { - lease->addr6 = *addrp; + memcpy(&lease->addr6, addrp, sizeof(struct in6_addr)); lease->flags |= lease_type; lease->iaid = 0; } + my_syslog(MS_DHCP | LOG_INFO, "lease6_allocate(): -"); return lease; } #endif diff --git a/src/rfc3315.c b/src/rfc3315.c index 3a2ed75..d416a90 100644 --- a/src/rfc3315.c +++ b/src/rfc3315.c @@ -1814,6 +1814,7 @@ static void update_leases(struct state *state, struct dhcp_context *context, str #ifdef HAVE_SCRIPT struct dhcp_netid *tagif = run_tag_if(state->tags); #endif + my_syslog(MS_DHCP | LOG_INFO, "update_leases(): +"); (void)context; @@ -1902,6 +1903,7 @@ static void update_leases(struct state *state, struct dhcp_context *context, str #endif } + my_syslog(MS_DHCP | LOG_INFO, "update_leases(): -"); } -- 2.7.4