[Olsr-dev] [PATCH v1 2/5] gateway: improve gw_default_update_handler a bit

Ferry Huberts (spam-protected)
Mon Jul 30 15:13:14 CEST 2012


From: Ferry Huberts <(spam-protected)>

protect against a null pointer deref

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

diff --git a/src/gateway_default_handler.c b/src/gateway_default_handler.c
index 132f203..d0ee880 100644
--- a/src/gateway_default_handler.c
+++ b/src/gateway_default_handler.c
@@ -223,9 +223,9 @@ static void gw_default_choosegw_handler(bool ipv4, bool ipv6) {
  * @param gw the gateway entry
  */
 static void gw_default_update_handler(struct gateway_entry *gw) {
-  bool v4changed = (gw == olsr_get_ipv4_inet_gateway(NULL))
+  bool v4changed = gw && (gw == olsr_get_ipv4_inet_gateway(NULL))
       && (!gw->ipv4 || (gw->ipv4nat && !olsr_cnf->smart_gw_allow_nat));
-  bool v6changed = (gw == olsr_get_ipv6_inet_gateway(NULL)) && !gw->ipv6;
+  bool v6changed = gw && (gw == olsr_get_ipv6_inet_gateway(NULL)) && !gw->ipv6;
 
   if (v4changed || v6changed) {
     olsr_gw_default_lookup_gateway(v4changed, v6changed);
-- 
1.7.11.2





More information about the Olsr-dev mailing list