[Olsr-dev] [PATCH v1 18/19] gateway: prevent 2 NULL dereferences

Ferry Huberts (spam-protected)
Thu Aug 23 15:12:42 CEST 2012


From: Ferry Huberts <(spam-protected)>

Signed-off-by: Ferry Huberts <(spam-protected)>
---
 src/gateway.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gateway.c b/src/gateway.c
index 7576ed2..8b11acb 100644
--- a/src/gateway.c
+++ b/src/gateway.c
@@ -509,7 +509,7 @@ bool olsr_set_inet_gateway(union olsr_ip_addr *originator, bool ipv4, bool ipv6)
   }
 
   /* handle IPv4 */
-  if (oldV4 != current_ipv4_gw) {
+  if (current_ipv4_gw && oldV4 != current_ipv4_gw) {
     if ((v4gw_tunnel = olsr_os_add_ipip_tunnel(&current_ipv4_gw->originator, true)) != NULL) {
       olsr_os_inetgw_tunnel_route(v4gw_tunnel->if_index, true, true);
     } else {
@@ -521,7 +521,7 @@ bool olsr_set_inet_gateway(union olsr_ip_addr *originator, bool ipv4, bool ipv6)
     }
   }
   /* handle IPv6 */
-  if (oldV6 != current_ipv6_gw) {
+  if (current_ipv6_gw && oldV6 != current_ipv6_gw) {
     if ((v6gw_tunnel = olsr_os_add_ipip_tunnel(&current_ipv6_gw->originator, false)) != NULL) {
       olsr_os_inetgw_tunnel_route(v6gw_tunnel->if_index, false, true);
     } else {
-- 
1.7.11.4





More information about the Olsr-dev mailing list