From: Alan T. DeKok Date: Fri, 13 Jan 2012 15:12:45 +0000 (+0100) Subject: Change asserts to run-time checks X-Git-Tag: release_2_2_0~203 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=751a7d204fa1ec9b56141404d6a9104fb8834f0a;p=thirdparty%2Ffreeradius-server.git Change asserts to run-time checks --- diff --git a/src/main/dhcpd.c b/src/main/dhcpd.c index 619254b468e..5ce83396627 100644 --- a/src/main/dhcpd.c +++ b/src/main/dhcpd.c @@ -201,7 +201,11 @@ static int dhcprelay_process_server_reply(REQUEST *request) request->packet->dst_ipaddr.ipaddr.ip4addr.s_addr = vp->vp_ipaddr; } else { vp = pairfind(request->packet->vps, DHCP2ATTR(264)); /* DHCP-Your-IP-Address */ - rad_assert(vp != NULL); + if (!vp) { + DEBUG("DHCP: Failed to find IP Address for request."); + return -1; + } + request->packet->dst_ipaddr.ipaddr.ip4addr.s_addr = vp->vp_ipaddr; /* @@ -409,7 +413,11 @@ static int dhcp_process(REQUEST *request) request->reply->dst_ipaddr.ipaddr.ip4addr.s_addr = vp->vp_ipaddr; } else { vp = pairfind(request->reply->vps, DHCP2ATTR(264)); /* DHCP-Your-IP-Address */ - rad_assert(vp != NULL); + if (!vp) { + DEBUG("DHCP: Failed to find IP Address for request."); + return -1; + } + request->reply->dst_ipaddr.ipaddr.ip4addr.s_addr = vp->vp_ipaddr; /* @@ -420,7 +428,9 @@ static int dhcp_process(REQUEST *request) */ if (request->reply->code == PW_DHCP_OFFER) { VALUE_PAIR *hwvp = pairfind(request->reply->vps, DHCP2ATTR(267)); /* DHCP-Client-Hardware-Address */ - rad_assert(hwvp != NULL); + + if (!hwvp) return -1; + if (fr_dhcp_add_arp_entry(request->reply->sockfd, sock->src_interface, hwvp, vp) < 0) { return -1; }