瀏覽代碼

DHCPIpUdpDecoder: oops.. don't stop receiving packets when we get an invalid packet

ambrop7 15 年之前
父節點
當前提交
90f74f7b07
共有 1 個文件被更改,包括 12 次插入7 次删除
  1. 12 7
      dhcpclient/DHCPIpUdpDecoder.c

+ 12 - 7
dhcpclient/DHCPIpUdpDecoder.c

@@ -46,36 +46,41 @@ static void input_handler_send (DHCPIpUdpDecoder *o, uint8_t *data, int data_len
     int pl_len;
     
     if (!ipv4_check(data, data_len, &iph, &pl, &pl_len)) {
-        return;
+        goto fail;
     }
     
     if (ntoh8(iph->protocol) != IPV4_PROTOCOL_UDP) {
-        return;
+        goto fail;
     }
     
     if (pl_len < sizeof(struct udp_header)) {
-        return;
+        goto fail;
     }
     struct udp_header *udph = (void *)pl;
     
     if (ntoh16(udph->source_port) != DHCP_SERVER_PORT) {
-        return;
+        goto fail;
     }
     
     if (ntoh16(udph->dest_port) != DHCP_CLIENT_PORT) {
-        return;
+        goto fail;
     }
     
     int udph_length = ntoh16(udph->length);
     if (udph_length < sizeof(*udph)) {
-        return;
+        goto fail;
     }
     if (udph_length > data_len - (pl - data)) {
-        return;
+        goto fail;
     }
     
     // pass payload to output
     PacketPassInterface_Sender_Send(o->output, (uint8_t *)(udph + 1), udph_length - sizeof(*udph));
+    
+    return;
+    
+fail:
+    PacketPassInterface_Done(&o->input);
 }
 
 static void output_handler_done (DHCPIpUdpDecoder *o)