[systemd-devel] [RFC][PATCH 1/2] resolve: resolved-manager: Avoid null dereference

philippedeswert at gmail.com philippedeswert at gmail.com
Sat Sep 13 02:24:53 PDT 2014


From: Philippe De Swert <philippedeswert at gmail.com>

hashmap_get can return null, so as we dereference it
immediately after calling it, we could crash.
It is unlikely to occur though I expect. I am however unsure
what error should be reported (if at all).

Coverity CID#1237656
---
 src/resolve/resolved-manager.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c
index f979897..ba175e6 100644
--- a/src/resolve/resolved-manager.c
+++ b/src/resolve/resolved-manager.c
@@ -1695,6 +1695,8 @@ int manager_ifindex_is_loopback(Manager *m, int ifindex) {
                 return -EINVAL;
 
         l = hashmap_get(m->links, INT_TO_PTR(ifindex));
+        if(!l)
+                return -EINVAL;
         if (l->flags & IFF_LOOPBACK)
                 return 1;
 
-- 
1.8.3.2



More information about the systemd-devel mailing list