mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-27 12:35:26 +00:00
Always check whether netif_default is NULL
In general, netif_default may be NULL, and various places in the code already check for this case before attempting to dereference the netif_default pointer. Some places do not perform this check though, and may cause null pointer dereferences if netif_default is not set. This patch adds NULL checks to those places as well.
This commit is contained in:
parent
31b0237c50
commit
0034abfa45
@ -177,7 +177,7 @@ ip4_route(const ip4_addr_t *dest)
|
||||
/* loopif is disabled, looopback traffic is passed through any netif */
|
||||
if (ip4_addr_isloopback(dest)) {
|
||||
/* don't check for link on loopback traffic */
|
||||
if (netif_is_up(netif_default)) {
|
||||
if (netif_default != NULL && netif_is_up(netif_default)) {
|
||||
return netif_default;
|
||||
}
|
||||
/* default netif is not up, just use any netif for loopback traffic */
|
||||
|
@ -94,7 +94,8 @@ ip6_route(const ip6_addr_t *src, const ip6_addr_t *dest)
|
||||
if (ip6_addr_islinklocal(dest)) {
|
||||
if (ip6_addr_isany(src)) {
|
||||
/* Use default netif, if Up. */
|
||||
if (!netif_is_up(netif_default) || !netif_is_link_up(netif_default)) {
|
||||
if (netif_default == NULL || !netif_is_up(netif_default) ||
|
||||
!netif_is_link_up(netif_default)) {
|
||||
return NULL;
|
||||
}
|
||||
return netif_default;
|
||||
@ -114,7 +115,8 @@ ip6_route(const ip6_addr_t *src, const ip6_addr_t *dest)
|
||||
}
|
||||
|
||||
/* netif not found, use default netif, if up */
|
||||
if (!netif_is_up(netif_default) || !netif_is_link_up(netif_default)) {
|
||||
if (netif_default == NULL || !netif_is_up(netif_default) ||
|
||||
!netif_is_link_up(netif_default)) {
|
||||
return NULL;
|
||||
}
|
||||
return netif_default;
|
||||
@ -172,7 +174,7 @@ ip6_route(const ip6_addr_t *src, const ip6_addr_t *dest)
|
||||
/* loopif is disabled, loopback traffic is passed through any netif */
|
||||
if (ip6_addr_isloopback(dest)) {
|
||||
/* don't check for link on loopback traffic */
|
||||
if (netif_is_up(netif_default)) {
|
||||
if (netif_default != NULL && netif_is_up(netif_default)) {
|
||||
return netif_default;
|
||||
}
|
||||
/* default netif is not up, just use any netif for loopback traffic */
|
||||
|
Loading…
x
Reference in New Issue
Block a user