From: Roy Marples Date: Sun, 13 Mar 2016 19:46:09 +0000 (+0000) Subject: It's possible to receive routing events for non existant interfaces, so abort gracefu... X-Git-Tag: v6.10.2~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6490fa98bf5b8dcaa63d204127bfbc524ac96ecd;p=thirdparty%2Fdhcpcd.git It's possible to receive routing events for non existant interfaces, so abort gracefully rather than asserting. --- diff --git a/if-bsd.c b/if-bsd.c index 4db0a0b0..8389d4ae 100644 --- a/if-bsd.c +++ b/if-bsd.c @@ -57,7 +57,6 @@ # include #endif -#include #include #include #include @@ -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; } diff --git a/if-linux.c b/if-linux.c index eae9be9b..dc1bb383 100644 --- a/if-linux.c +++ b/if-linux.c @@ -46,7 +46,6 @@ #include #include -#include #include #include #include @@ -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