1diff --git a/src/blockdata.c b/src/blockdata.c 2index 0986285..852c961 100644 3--- a/src/blockdata.c 4+++ b/src/blockdata.c 5@@ -15,16 +15,22 @@ 6 */ 7 8 #include "dnsmasq.h" 9+#include <assert.h> 10 11 static struct blockdata *keyblock_free; 12 static unsigned int blockdata_count, blockdata_hwm, blockdata_alloced; 13 14+void *total_allocated[200] = {0}; 15+static int fuzz_total_alloc_ptr = 0; 16+ 17 static void blockdata_expand(int n) 18 { 19 struct blockdata *new = whine_malloc(n * sizeof(struct blockdata)); 20 21 if (new) 22 { 23+ assert(fuzz_total_alloc_ptr < 200); 24+ total_allocated[fuzz_total_alloc_ptr++] = (void*)new; 25 int i; 26 27 new[n-1].next = keyblock_free; 28@@ -45,11 +51,23 @@ void blockdata_init(void) 29 blockdata_count = 0; 30 blockdata_hwm = 0; 31 32+ fuzz_total_alloc_ptr = 0; 33+ for (int m = 0; m < 200; m++) 34+ total_allocated[m] = NULL; 35+ 36 /* Note that daemon->cachesize is enforced to have non-zero size if OPT_DNSSEC_VALID is set */ 37 if (option_bool(OPT_DNSSEC_VALID)) 38 blockdata_expand(daemon->cachesize); 39 } 40 41+void fuzz_blockdata_cleanup() { 42+ for (int i = 0; i < 200; i++) { 43+ if (total_allocated[i] != NULL) { 44+ free(total_allocated[i]); 45+ } 46+ } 47+} 48+ 49 void blockdata_report(void) 50 { 51 my_syslog(LOG_INFO, _("pool memory in use %zu, max %zu, allocated %zu"), 52diff --git a/src/dhcp.c b/src/dhcp.c 53index e500bc2..7215590 100644 54--- a/src/dhcp.c 55+++ b/src/dhcp.c 56@@ -183,18 +183,26 @@ void dhcp_packet(time_t now, int pxe_fd) 57 recvtime = tv.tv_sec; 58 59 if (msg.msg_controllen >= sizeof(struct cmsghdr)) 60- for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr)) 61- if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_PKTINFO) 62- { 63- union { 64- unsigned char *c; 65- struct in_pktinfo *p; 66- } p; 67- p.c = CMSG_DATA(cmptr); 68- iface_index = p.p->ipi_ifindex; 69- if (p.p->ipi_addr.s_addr != INADDR_BROADCAST) 70- unicast_dest = 1; 71- } 72+ { 73+ int tmp_val = 0; 74+ for (cmptr = CMSG_FIRSTHDR(&msg); 75+ cmptr && tmp_val < 1; 76+ tmp_val++) { 77+ //cmptr = CMSG_NXTHDR(&msg, cmptr)) { 78+ tmp_val++; 79+ if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_PKTINFO) 80+ { 81+ union { 82+ unsigned char *c; 83+ struct in_pktinfo *p; 84+ } p; 85+ p.c = CMSG_DATA(cmptr); 86+ iface_index = p.p->ipi_ifindex; 87+ if (p.p->ipi_addr.s_addr != INADDR_BROADCAST) 88+ unicast_dest = 1; 89+ } 90+ } 91+ } 92 93 #elif defined(HAVE_BSD_NETWORK) 94 if (msg.msg_controllen >= sizeof(struct cmsghdr)) 95diff --git a/src/dhcp6.c b/src/dhcp6.c 96index ae1f5c1..ce7397d 100644 97--- a/src/dhcp6.c 98+++ b/src/dhcp6.c 99@@ -116,10 +116,14 @@ void dhcp6_packet(time_t now) 100 msg.msg_iov = &daemon->dhcp_packet; 101 msg.msg_iovlen = 1; 102 103- if ((sz = recv_dhcp_packet(daemon->dhcp6fd, &msg)) == -1) 104+ if ((sz = recv_dhcp_packet(daemon->dhcp6fd, &msg)) == -1){ 105 return; 106- 107- for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr)) 108+ } 109+ 110+ int tmp_val = 0; 111+// for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr)) { 112+ for (cmptr = CMSG_FIRSTHDR(&msg); cmptr && tmp_val < 1; tmp_val++) { 113+ tmp_val++; 114 if (cmptr->cmsg_level == IPPROTO_IPV6 && cmptr->cmsg_type == daemon->v6pktinfo) 115 { 116 union { 117@@ -131,9 +135,11 @@ void dhcp6_packet(time_t now) 118 if_index = p.p->ipi6_ifindex; 119 dst_addr = p.p->ipi6_addr; 120 } 121+ } 122 123- if (!indextoname(daemon->dhcp6fd, if_index, ifr.ifr_name)) 124+ if (!indextoname(daemon->dhcp6fd, if_index, ifr.ifr_name)) { 125 return; 126+ } 127 128 if ((port = relay_reply6(&from, sz, ifr.ifr_name)) != 0) 129 { 130diff --git a/src/netlink.c b/src/netlink.c 131index 7840ef9..2419897 100644 132--- a/src/netlink.c 133+++ b/src/netlink.c 134@@ -197,8 +197,13 @@ int iface_enumerate(int family, void *parm, int (*callback)()) 135 if (errno != 0) 136 return 0; 137 138+ int valval = 0; 139 while (1) 140 { 141+ valval++; 142+ if (valval > 300) { 143+ return -1; 144+ } 145 if ((len = netlink_recv(0)) == -1) 146 { 147 if (errno == ENOBUFS) 148diff --git a/src/network.c b/src/network.c 149index 296c7bd..c03961a 100644 150--- a/src/network.c 151+++ b/src/network.c 152@@ -697,6 +697,7 @@ int enumerate_interfaces(int reset) 153 struct auth_zone *zone; 154 #endif 155 struct server *serv; 156+ int iteration = 0; 157 158 /* Do this max once per select cycle - also inhibits netlink socket use 159 in TCP child processes. */ 160@@ -734,6 +735,10 @@ int enumerate_interfaces(int reset) 161 } 162 163 again: 164+ if (iteration > 100) { 165+ return 0; 166+ } 167+ iteration += 1; 168 /* Mark interfaces for garbage collection */ 169 for (iface = daemon->interfaces; iface; iface = iface->next) 170 iface->found = 0; 171