diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-01-18 14:51:44 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-01-18 14:51:44 +0000 |
commit | 09b5110b050908e02e2b688f1e9fbaff40394f16 (patch) | |
tree | dc43d614fee380c29dde33e8d48f3dcc26e56a8b /sys | |
parent | 1ee71c250ba263ffe0f34a6ffbe28ba33d0f4fb8 (diff) |
Do not even try to dereference a NULL pointer.
Found the hard way by Peter N. M. Hansteen.
ok claudio@, phessler@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/route.c | 6 |
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); } |