From 38db08c668225b7e745fb5d3def042952e660ac9 Mon Sep 17 00:00:00 2001 From: knakahara Date: Wed, 14 Mar 2018 07:56:32 +0000 Subject: [PATCH] Fix error checking in in6_gif_ctlinput(). if_gif.c:r1.133 introduces gif_update_variant() which ensure ifp->if_flags is set IFF_RUNNING when gif_softc->gif_var->gv_{psrc,pdst} are not null. So, in6_gif_ctlinput() is not required IFF_RUNNING checking. In contrast, it is required gv_{psrc,pdst} NULL checking. --- sys/netinet6/in6_gif.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/netinet6/in6_gif.c b/sys/netinet6/in6_gif.c index 5b4d81d8e04c..a035f58e9f23 100644 --- a/sys/netinet6/in6_gif.c +++ b/sys/netinet6/in6_gif.c @@ -1,4 +1,4 @@ -/* $NetBSD: in6_gif.c,v 1.90 2018/01/10 11:13:26 knakahara Exp $ */ +/* $NetBSD: in6_gif.c,v 1.91 2018/03/14 07:56:32 knakahara Exp $ */ /* $KAME: in6_gif.c,v 1.62 2001/07/29 04:27:25 itojun Exp $ */ /* @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: in6_gif.c,v 1.90 2018/01/10 11:13:26 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in6_gif.c,v 1.91 2018/03/14 07:56:32 knakahara Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -459,9 +459,11 @@ in6_gif_ctlinput(int cmd, const struct sockaddr *sa, void *d, void *eparg) if (!ip6) return NULL; - if ((sc->gif_if.if_flags & IFF_RUNNING) == 0) - return NULL; var = gif_getref_variant(sc, &psref); + if (var->gv_psrc == NULL || var->gv_pdst == NULL) { + gif_putref_variant(var, &psref); + return NULL; + } if (var->gv_psrc->sa_family != AF_INET6) { gif_putref_variant(var, &psref); return NULL;