@@ -100,8 +100,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
100100 memcpy (pkt , data , size );
101101 if (size > sizeof (* eth )) {
102102 static size_t i ;
103- // uint16_t eth_types[] = {0x800, 0x806, 0x86dd}; // IPv4, ARP, IPv6
104- uint16_t eth_types [] = {0x800 , 0x806 }; // IPv4, ARP, skip IPv6 until we merge it ***
103+ uint16_t eth_types [] = {0x800 , 0x806 , 0x86dd }; // IPv4, ARP, IPv6
105104 memcpy (eth -> dst , mif .mac , 6 ); // Set valid destination MAC
106105 // send all handled eth types, then 2 random ones
107106 if (i >= (sizeof (eth_types ) / sizeof (eth_types [0 ]) + 2 )) i = 0 ;
@@ -128,7 +127,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
128127 }
129128 }
130129 } else if (eth -> type == mg_htons (0x806 )) { // ARP
131- #if 0
130+ 132131 } else if (eth -> type == mg_htons (0x86dd ) && size > (sizeof (* eth ) + sizeof (struct ip6 ))) { // IPv6
133132 static size_t j ;
134133 uint8_t ip6_protos [] = {6 , 17 , 58 }; // TCP, UDP, ICMPv6
@@ -142,19 +141,13 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
142141 } else if (ip6 -> next == 58 ) { // ICMPv6
143142 if (size >= (sizeof (* eth ) + sizeof (struct ip6 ) + sizeof (struct icmp6 ))) {
144143 static size_t k ;
145- uint16_t icmp6_types [] = {128 , 134 , 135 , 136 }; // Echo Request, RA, NS, NA
144+ uint8_t icmp6_types [] = {128 , 134 , 135 , 136 }; // Echo Request, RA, NS, NA
146145 struct icmp6 * icmp6 = (struct icmp6 * ) (ip6 + 1 );
147146 // send all handled ICMPv6 types, then 2 random ones
148147 if (k >= (sizeof (icmp6_types ) / sizeof (icmp6_types [0 ]) + 2 )) k = 0 ;
149- if (k < (sizeof (icmp6_types ) / sizeof (icmp6_types [0 ]))) icmp6 -> type = mg_htons ( icmp6_types [k ++ ]) ;
148+ if (k < (sizeof (icmp6_types ) / sizeof (icmp6_types [0 ]))) icmp6 -> type = icmp6_types [k ++ ];
150149 }
151150 }
152- #else
153- } else if (eth -> type == mg_htons (0x86dd )) { // IPv6
154- free (pkt );
155- mg_mgr_free (& mgr );
156- return 0 ;
157- #endif
158151 }
159152 }
160153
0 commit comments