From ea9cd0f05e72ccc8be83034d43c11dbbd76cafed Mon Sep 17 00:00:00 2001 From: mpi Date: Sun, 18 Jan 2015 14:51:43 +0000 Subject: [PATCH] Do not even try to dereference a NULL pointer. Found the hard way by Peter N. M. Hansteen. ok claudio@, phessler@ --- sys/net/route.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/net/route.c b/sys/net/route.c index 90ad7f11c92..74deb674779 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.199 2015/01/13 12:14:00 mpi Exp $ */ +/* $OpenBSD: route.c,v 1.200 2015/01/18 14:51:43 mpi Exp $ */ /* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */ /* @@ -1045,8 +1045,10 @@ rt_checkgate(struct ifnet *ifp, struct rtentry *rt, struct sockaddr *dst, if ((rt->rt_flags & RTF_UP) == 0) { rt = rtalloc(dst, RT_REPORT|RT_RESOLVE, rtableid); + if (rt == NULL) + return (EHOSTUNREACH); rt->rt_refcnt--; - if (rt == NULL || rt->rt_ifp != ifp) + if (rt->rt_ifp != ifp) return (EHOSTUNREACH); } -- 2.20.1