interface: fix possible null pointer dereference
authorPetr Štetiar <ynezz@true.cz>
Tue, 13 Oct 2020 13:26:01 +0000 (15:26 +0200)
committerPetr Štetiar <ynezz@true.cz>
Tue, 13 Oct 2020 13:27:49 +0000 (15:27 +0200)
Fixes following issue reported by clang-12 static analyzer:

 mdnsd/interface.c:250:6: warning: Access to field 'ipi_ifindex' results in a dereference of a null pointer (loaded from variable 'inp')
         if (inp->ipi_ifindex != iface->ifindex)
             ^~~~~~~~~~~~~~~~

 mdnsd/interface.c:323:6: warning: Access to field 'ipi6_ifindex' results in a dereference of a null pointer (loaded from variable 'inp')
         if (inp->ipi6_ifindex != iface->ifindex)
             ^~~~~~~~~~~~~~~~~

Signed-off-by: Petr Štetiar <ynezz@true.cz>
interface.c

index 690e8579a44c62ade3b962258b5d3468b966f0a3..5fb9bad072edbec2bcb43c12d6c0a37a588a5a2a 100644 (file)
@@ -233,6 +233,9 @@ read_socket4(struct uloop_fd *u, unsigned int events)
                }
        }
 
+       if (!inp)
+               return;
+
        if (debug > 1) {
                char buf[256];
 
@@ -308,6 +311,9 @@ read_socket6(struct uloop_fd *u, unsigned int events)
                }
        }
 
+       if (!inp)
+               return;
+
        if (debug > 1) {
                char buf[256];