From 199aa0aea63a91523257ef3527f3f842666542af Mon Sep 17 00:00:00 2001 From: DavidKorczynski Date: Tue, 8 Feb 2022 22:51:27 +0000 Subject: [PATCH] dnsmasq: fix patch (#7252) --- projects/dnsmasq/fuzz_header.h | 2 +- projects/dnsmasq/fuzz_patch.patch | 78 +++++++++++-------------------- 2 files changed, 29 insertions(+), 51 deletions(-) diff --git a/projects/dnsmasq/fuzz_header.h b/projects/dnsmasq/fuzz_header.h index 748e709fc..a865b9c17 100644 --- a/projects/dnsmasq/fuzz_header.h +++ b/projects/dnsmasq/fuzz_header.h @@ -363,7 +363,7 @@ int init_daemon(const uint8_t **data2, size_t *size2) { CLEAN_IF_NULL(dr_interface) dr->interface = dr_interface; dr->next = NULL; - dr->current = NULL; + //dr->current = NULL; daemon->relay4 = dr; // deamon->bridges diff --git a/projects/dnsmasq/fuzz_patch.patch b/projects/dnsmasq/fuzz_patch.patch index 6196c93b4..16943e7c5 100644 --- a/projects/dnsmasq/fuzz_patch.patch +++ b/projects/dnsmasq/fuzz_patch.patch @@ -1,5 +1,5 @@ diff --git a/src/blockdata.c b/src/blockdata.c -index 0986285..852c961 100644 +index 4c26155..9612447 100644 --- a/src/blockdata.c +++ b/src/blockdata.c @@ -15,16 +15,22 @@ @@ -50,71 +50,49 @@ index 0986285..852c961 100644 { my_syslog(LOG_INFO, _("pool memory in use %zu, max %zu, allocated %zu"), diff --git a/src/dhcp.c b/src/dhcp.c -index e500bc2..7215590 100644 +index 6104c87..0a42ac3 100644 --- a/src/dhcp.c +++ b/src/dhcp.c -@@ -183,18 +183,26 @@ void dhcp_packet(time_t now, int pxe_fd) +@@ -186,7 +186,13 @@ void dhcp_packet(time_t now, int pxe_fd) recvtime = tv.tv_sec; - + if (msg.msg_controllen >= sizeof(struct cmsghdr)) - for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr)) -- if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_PKTINFO) -- { -- union { -- unsigned char *c; -- struct in_pktinfo *p; -- } p; -- p.c = CMSG_DATA(cmptr); -- iface_index = p.p->ipi_ifindex; -- if (p.p->ipi_addr.s_addr != INADDR_BROADCAST) -- unicast_dest = 1; -- } + { + int tmp_val = 0; -+ for (cmptr = CMSG_FIRSTHDR(&msg); -+ cmptr && tmp_val < 1; -+ tmp_val++) { -+ //cmptr = CMSG_NXTHDR(&msg, cmptr)) { ++ for (cmptr = CMSG_FIRSTHDR(&msg); ++ cmptr && tmp_val < 1; ++ tmp_val++) { ++ //cmptr = CMSG_NXTHDR(&msg, cmptr)) { + tmp_val++; -+ if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_PKTINFO) -+ { -+ union { -+ unsigned char *c; -+ struct in_pktinfo *p; -+ } p; -+ p.c = CMSG_DATA(cmptr); -+ iface_index = p.p->ipi_ifindex; -+ if (p.p->ipi_addr.s_addr != INADDR_BROADCAST) -+ unicast_dest = 1; -+ } + if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_PKTINFO) + { + union { +@@ -198,6 +204,8 @@ void dhcp_packet(time_t now, int pxe_fd) + if (p.p->ipi_addr.s_addr != INADDR_BROADCAST) + unicast_dest = 1; + } + } + } #elif defined(HAVE_BSD_NETWORK) if (msg.msg_controllen >= sizeof(struct cmsghdr)) diff --git a/src/dhcp6.c b/src/dhcp6.c -index ae1f5c1..ce7397d 100644 +index edb87a4..937b5a7 100644 --- a/src/dhcp6.c +++ b/src/dhcp6.c -@@ -116,10 +116,14 @@ void dhcp6_packet(time_t now) - msg.msg_iov = &daemon->dhcp_packet; - msg.msg_iovlen = 1; +@@ -123,7 +123,9 @@ void dhcp6_packet(time_t now) + (union mysockaddr *)&from, NULL, DHCPV6_SERVER_PORT); + #endif -- if ((sz = recv_dhcp_packet(daemon->dhcp6fd, &msg)) == -1) -+ if ((sz = recv_dhcp_packet(daemon->dhcp6fd, &msg)) == -1){ - return; -- - for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr)) -+ } -+ + int tmp_val = 0; -+// for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr)) { + for (cmptr = CMSG_FIRSTHDR(&msg); cmptr && tmp_val < 1; tmp_val++) { -+ tmp_val++; ++ tmp_val++; if (cmptr->cmsg_level == IPPROTO_IPV6 && cmptr->cmsg_type == daemon->v6pktinfo) { union { -@@ -131,9 +135,11 @@ void dhcp6_packet(time_t now) +@@ -135,9 +137,11 @@ void dhcp6_packet(time_t now) if_index = p.p->ipi6_ifindex; dst_addr = p.p->ipi6_addr; } @@ -125,13 +103,13 @@ index ae1f5c1..ce7397d 100644 return; + } - if (relay_reply6(&from, sz, ifr.ifr_name)) - { + if (relay_reply6(&from, sz, ifr.ifr_name)) + { diff --git a/src/netlink.c b/src/netlink.c -index 7840ef9..2419897 100644 +index da82943..819b3c0 100644 --- a/src/netlink.c +++ b/src/netlink.c -@@ -197,8 +197,13 @@ int iface_enumerate(int family, void *parm, int (*callback)()) +@@ -190,8 +190,13 @@ int iface_enumerate(int family, void *parm, int (*callback)()) if (errno != 0) return 0; @@ -146,10 +124,10 @@ index 7840ef9..2419897 100644 { if (errno == ENOBUFS) diff --git a/src/network.c b/src/network.c -index 296c7bd..c03961a 100644 +index 4453b05..3740cf3 100644 --- a/src/network.c +++ b/src/network.c -@@ -697,6 +697,7 @@ int enumerate_interfaces(int reset) +@@ -696,6 +696,7 @@ int enumerate_interfaces(int reset) struct auth_zone *zone; #endif struct server *serv; @@ -157,7 +135,7 @@ index 296c7bd..c03961a 100644 /* Do this max once per select cycle - also inhibits netlink socket use in TCP child processes. */ -@@ -734,6 +735,10 @@ int enumerate_interfaces(int reset) +@@ -733,6 +734,10 @@ int enumerate_interfaces(int reset) } again: