Patchwork [50/60] slirp: Don't crash on packets from 0.0.0.0/8.

login
register
mail settings
Submitter Michael Tokarev
Date Feb. 4, 2013, 10:41 a.m.
Message ID <1359974470-17044-51-git-send-email-mjt@msgid.tls.msk.ru>
Download mbox | patch
Permalink /patch/217860/
State New
Headers show

Comments

Michael Tokarev - Feb. 4, 2013, 10:41 a.m.
From: Nickolai Zeldovich <nickolai@csail.mit.edu>

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.

Signed-off-by: Nickolai Zeldovich <nickolai@csail.mit.edu>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
(cherry picked from commit 1a89b60885ccc2abf7cc50275fcee70d0347425e)

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 slirp/arp_table.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch

diff --git a/slirp/arp_table.c b/slirp/arp_table.c
index 5d7b8ac..bf698c1 100644
--- a/slirp/arp_table.c
+++ b/slirp/arp_table.c
@@ -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 */