summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2015-01-18 14:51:43 +0000
committermpi <mpi@openbsd.org>2015-01-18 14:51:43 +0000
commitea9cd0f05e72ccc8be83034d43c11dbbd76cafed (patch)
tree13173b714eecd6a1df747363c9cb39e626463706
parentComplete synchronous abort method modeled after the existing ones. (diff)
downloadwireguard-openbsd-ea9cd0f05e72ccc8be83034d43c11dbbd76cafed.tar.xz
wireguard-openbsd-ea9cd0f05e72ccc8be83034d43c11dbbd76cafed.zip
Do not even try to dereference a NULL pointer.
Found the hard way by Peter N. M. Hansteen. ok claudio@, phessler@
-rw-r--r--sys/net/route.c6
1 files 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);
}