Skip to contentSkip to conversation

slirp: Don't crash on packets from 0.0.0.0/8.

PATCH Applied Nickolai Zeldovich 2 participants 2 messages Nov 12, 2012 – Nov 15, 2012

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 slirp: Don't crash on packets from 0.0.0.0/8.

LWIP can generate packets with a source of 0.0.0.0, which triggers an assertion failure in arp_table_add(). Instead of crashing, simply return to avoid adding an invalid ARP table entry.

---
 slirp/arp_table.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Change from v1: adhere to qemu's code style (put braces around all indentation blocks).

slirp/arp_table.c +3 -1
index 5d7b8ac..bf698c1 100644
@@ -38,7 +38,9 @@ void arp_table_add(Slirp *slirp, uint32_t ip_addr, uint8_t ethaddr[ETH_ALEN])
                 ethaddr[3], ethaddr[4], ethaddr[5]));
 
     /* Check 0.0.0.0/8 invalid source-only addresses */
-    assert((ip_addr & htonl(~(0xf << 28))) != 0);
+    if ((ip_addr & htonl(~(0xf << 28))) == 0) {
+        return;
+    }
 
     if (ip_addr == 0xffffffff || ip_addr == broadcast_addr) {
         /* Do not register broadcast addresses */
Signature · 1 line
1.7.10.4
Applied
#1 lore raw
Quoted 19 lines · Nickolai Zeldovich

LWIP can generate packets with a source of 0.0.0.0, which triggers an assertion failure in arp_table_add(). Instead of crashing, simply return to avoid adding an invalid ARP table entry.

---
 slirp/arp_table.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Change from v1: adhere to qemu's code style (put braces around all indentation blocks).

slirp/arp_table.c +0 -0
index 5d7b8ac..bf698c1 100644

slirp/arp_table.c void arp_table_add(Slirp *slirp, uint32_t ip_addr, uint8_t ethaddr[ETH_ALEN]) · line 46

Quoted 10 lines
slirp/arp_table.c +3 -1
@@ -38,7 +38,9 @@ void arp_table_add(Slirp *slirp, uint32_t ip_addr, uint8_t ethaddr[ETH_ALEN])
                 ethaddr[3], ethaddr[4], ethaddr[5]));
 
     /* Check 0.0.0.0/8 invalid source-only addresses */
-    assert((ip_addr & htonl(~(0xf << 28))) != 0);
+    if ((ip_addr & htonl(~(0xf << 28))) == 0) {
+        return;
+    }
 
     if (ip_addr == 0xffffffff || ip_addr == broadcast_addr) {
         /* Do not register broadcast addresses */

Thanks, applied to slirp queue.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux