| 1 | --- a/src/dhcp.c |
| 2 | +++ b/src/dhcp.c |
| 3 | @@ -134,7 +134,7 @@ void dhcp_packet(time_t now, int pxe_fd) |
| 4 | struct iovec iov; |
| 5 | ssize_t sz; |
| 6 | int iface_index = 0, unicast_dest = 0, is_inform = 0; |
| 7 | - struct in_addr iface_addr; |
| 8 | + struct in_addr iface_addr, *addrp = NULL; |
| 9 | struct iface_param parm; |
| 10 | #ifdef HAVE_LINUX_NETWORK |
| 11 | struct arpreq arp_req; |
| 12 | @@ -246,11 +246,9 @@ void dhcp_packet(time_t now, int pxe_fd) |
| 13 | |
| 14 | ifr.ifr_addr.sa_family = AF_INET; |
| 15 | if (ioctl(daemon->dhcpfd, SIOCGIFADDR, &ifr) != -1 ) |
| 16 | - iface_addr = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr; |
| 17 | - else |
| 18 | { |
| 19 | - my_syslog(MS_DHCP | LOG_WARNING, _("DHCP packet received on %s which has no address"), ifr.ifr_name); |
| 20 | - return; |
| 21 | + addrp = &iface_addr; |
| 22 | + iface_addr = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr; |
| 23 | } |
| 24 | |
| 25 | for (tmp = daemon->dhcp_except; tmp; tmp = tmp->next) |
| 26 | @@ -272,7 +270,7 @@ void dhcp_packet(time_t now, int pxe_fd) |
| 27 | parm.current = NULL; |
| 28 | parm.ind = iface_index; |
| 29 | |
| 30 | - if (!iface_check(AF_INET, (struct all_addr *)&iface_addr, ifr.ifr_name)) |
| 31 | + if (!iface_check(AF_INET, (struct all_addr *)addrp, ifr.ifr_name)) |
| 32 | { |
| 33 | /* If we failed to match the primary address of the interface, see if we've got a --listen-address |
| 34 | for a secondary */ |
| 35 | @@ -291,7 +289,13 @@ void dhcp_packet(time_t now, int pxe_fd) |
| 36 | there is more than one address on the interface in the same subnet */ |
| 37 | complete_context(match.addr, iface_index, match.netmask, match.broadcast, &parm); |
| 38 | } |
| 39 | - |
| 40 | + |
| 41 | + if (!addrp) |
| 42 | + { |
| 43 | + my_syslog(MS_DHCP | LOG_WARNING, _("DHCP packet received on %s which has no address"), ifr.ifr_name); |
| 44 | + return; |
| 45 | + } |
| 46 | + |
| 47 | if (!iface_enumerate(AF_INET, &parm, complete_context)) |
| 48 | return; |
| 49 | |
| 50 | |