diff options
author | 2015-09-10 06:00:37 +0000 | |
---|---|---|
committer | 2015-09-10 06:00:37 +0000 | |
commit | cc50908e48ffdacce2c1656998078f202d6b565a (patch) | |
tree | 6d8b73bc70275d20a75d3cc92255fc4ce2253549 | |
parent | Remove SOCKET_PROTOCOL, a redundant define that was only used once. (diff) | |
download | wireguard-openbsd-cc50908e48ffdacce2c1656998078f202d6b565a.tar.xz wireguard-openbsd-cc50908e48ffdacce2c1656998078f202d6b565a.zip |
only try and reference an ifp in if_get if we actually find one in
the map.
avoids a NULL deref jsg@ found
-rw-r--r-- | sys/net/if.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index fadedd86a96..77791b35b1f 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.364 2015/09/09 16:01:10 dlg Exp $ */ +/* $OpenBSD: if.c,v 1.365 2015/09/10 06:00:37 dlg Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -1231,10 +1231,13 @@ if_get(unsigned int index) { struct ifnet *ifp = NULL; - if (index < if_indexlim) + if (index < if_indexlim) { ifp = ifindex2ifnet[index]; + if (ifp != NULL) + if_ref(ifp); + } - return (if_ref(ifp)); + return (ifp); } struct ifnet * |