dnsproxy: Make sure we are not accessing null hash
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Fri, 22 Mar 2013 14:15:19 +0000 (16:15 +0200)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Fri, 22 Mar 2013 14:21:28 +0000 (16:21 +0200)
If dnsproxy is not in use, like when connman has been started
with -r option, then the listener_table will be NULL which can
cause crash in hash table lookup call.

src/dnsproxy.c

index f698cfd..7a9ca91 100644 (file)
@@ -2916,6 +2916,9 @@ int __connman_dnsproxy_add_listener(int index)
        if (index < 0)
                return -EINVAL;
 
+       if (listener_table == NULL)
+               return 0;
+
        if (g_hash_table_lookup(listener_table, GINT_TO_POINTER(index)) != NULL)
                return 0;
 
@@ -2947,6 +2950,9 @@ void __connman_dnsproxy_remove_listener(int index)
 
        DBG("index %d", index);
 
+       if (listener_table == NULL)
+               return;
+
        ifdata = g_hash_table_lookup(listener_table, GINT_TO_POINTER(index));
        if (ifdata == NULL)
                return;