From e304a89ddb8a47cc4a8c44254221f360bcc24950 Mon Sep 17 00:00:00 2001 From: Joseph Henry Date: Thu, 19 Nov 2020 10:08:31 -0800 Subject: [PATCH] Add check for netif before use in VirtualTap - Fixes bug mentioned in ticket #85 --- src/VirtualTap.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/VirtualTap.cpp b/src/VirtualTap.cpp index c9063d2..45eb853 100644 --- a/src/VirtualTap.cpp +++ b/src/VirtualTap.cpp @@ -482,15 +482,19 @@ void _lwip_eth_rx(VirtualTap *tap, const MAC &from, const MAC &to, unsigned int int err; if (Utils::ntoh(ethhdr.type) == 0x800 || Utils::ntoh(ethhdr.type) == 0x806) { - if ((err = ((struct netif *)tap->netif4)->input(p, (struct netif *)tap->netif4)) != ERR_OK) { - DEBUG_ERROR("packet input error (%d)", err); - pbuf_free(p); + if (tap->netif4) { + if ((err = ((struct netif *)tap->netif4)->input(p, (struct netif *)tap->netif4)) != ERR_OK) { + DEBUG_ERROR("packet input error (%d)", err); + pbuf_free(p); + } } } if (Utils::ntoh(ethhdr.type) == 0x86DD) { - if ((err = ((struct netif *)tap->netif6)->input(p, (struct netif *)tap->netif6)) != ERR_OK) { - DEBUG_ERROR("packet input error (%d)", err); - pbuf_free(p); + if (tap->netif6) { + if ((err = ((struct netif *)tap->netif6)->input(p, (struct netif *)tap->netif6)) != ERR_OK) { + DEBUG_ERROR("packet input error (%d)", err); + pbuf_free(p); + } } } }