Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 04 May 2004 13:42:20 +0100
From:      Colin Percival <colin.percival@wadham.ox.ac.uk>
To:        freebsd-net@freebsd.org
Subject:   [patch] Verify that ifaddr_byindex(foo) != NULL
Message-ID:  <6.1.0.6.1.20040504133711.03d1ce18@popserver.sfu.ca>

next in thread | raw e-mail | index | archive | help
  Could someone confirm for me that this looks sensible?  I don't
know anything about this code, but if we're going to check that
0 < ifp->if_index <= if_index, it seems that we should also be
checking that ifp->if_index corresponds to an interface which
still exists (rather than a gap left behind when an interface was
removed).

Colin Percival

Index: src/sys/netinet/ip_input.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/ip_input.c,v
retrieving revision 1.270
diff -u -p -r1.270 ip_input.c
--- src/sys/netinet/ip_input.c	2 May 2004 15:10:16 -0000	1.270
+++ src/sys/netinet/ip_input.c	4 May 2004 12:37:02 -0000
@@ -2053,7 +2053,8 @@ ip_savecontrol(inp, mp, ip, m)
 		struct sockaddr_dl *sdl2 = &sdlbuf.sdl;

 		if (((ifp = m->m_pkthdr.rcvif))
-		&& ( ifp->if_index && (ifp->if_index <= if_index))) {
+		&& ( ifp->if_index && (ifp->if_index <= if_index)) &&
+		    (ifaddr_byindex(ifp->if_index) != NULL)) {
 			sdp = (struct sockaddr_dl *)
 			    (ifaddr_byindex(ifp->if_index)->ifa_addr);
 			/*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6.1.0.6.1.20040504133711.03d1ce18>