From: mpi Date: Sun, 18 Jan 2015 14:51:43 +0000 (+0000) Subject: Do not even try to dereference a NULL pointer. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=ea9cd0f05e72ccc8be83034d43c11dbbd76cafed;p=openbsd Do not even try to dereference a NULL pointer. Found the hard way by Peter N. M. Hansteen. ok claudio@, phessler@ --- 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); }