]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
It's possible to receive routing events for non existant interfaces, so abort gracefu...
authorRoy Marples <roy@marples.name>
Sun, 13 Mar 2016 19:46:09 +0000 (19:46 +0000)
committerRoy Marples <roy@marples.name>
Sun, 13 Mar 2016 19:46:09 +0000 (19:46 +0000)
if-bsd.c
if-linux.c

index 4db0a0b01e4531c3426544d91c0541c215a01622..8389d4aebba8dcf69040c58f62e100f80512f50a 100644 (file)
--- a/if-bsd.c
+++ b/if-bsd.c
@@ -57,7 +57,6 @@
 #  include <net80211/ieee80211_ioctl.h>
 #endif
 
-#include <assert.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <fnmatch.h>
@@ -550,8 +549,10 @@ if_copyrt(struct dhcpcd_ctx *ctx, struct rt *rt, struct rt_msghdr *rtm)
                        rt->iface = ia->iface;
        }
 
-       assert(rt->iface != NULL);
-
+       if (rt->iface == NULL) {
+               errno = ESRCH;
+               return -1;
+       }
        return 0;
 }
 
@@ -965,8 +966,10 @@ if_copyrt6(struct dhcpcd_ctx *ctx, struct rt6 *rt, struct rt_msghdr *rtm)
                        rt->iface = ia->iface;
        }
 
-       assert(rt->iface != NULL);
-
+       if (rt->iface == NULL) {
+               errno = ESRCH;
+               return -1;
+       }
        return 0;
 }
 
index eae9be9b658a2b917de1c91867842ac6ed83366d..dc1bb383c2d06e2ea16d6baf8aec91b345660fca 100644 (file)
@@ -46,7 +46,6 @@
 #include <netinet/in.h>
 #include <net/route.h>
 
-#include <assert.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <ctype.h>
@@ -450,7 +449,11 @@ if_copyrt(struct dhcpcd_ctx *ctx, struct rt *rt, struct nlmsghdr *nlm)
                if ((ap = ipv4_findaddr(ctx, &rt->src)))
                        rt->iface = ap->iface;
        }
-       assert(rt->iface != NULL);
+
+       if (rt->iface == NULL) {
+               errno = ESRCH;
+               return -1;
+       }
        return 0;
 }
 #endif
@@ -520,7 +523,10 @@ if_copyrt6(struct dhcpcd_ctx *ctx, struct rt6 *rt, struct nlmsghdr *nlm)
                rta = RTA_NEXT(rta, len);
        }
 
-       assert(rt->iface != NULL);
+       if (rt->iface == NULL) {
+               errno = ESRCH;
+               return -1;
+       }
        return 0;
 }
 #endif