svn commit: r192251 - stable/7/lib/libc/net

Bruce M Simpson bms at FreeBSD.org
Sun May 17 15:42:42 UTC 2009


Author: bms
Date: Sun May 17 15:42:41 2009
New Revision: 192251
URL: http://svn.freebsd.org/changeset/base/192251

Log:
  MFC rev 191654:
  Fix an obvious bug in getsourcefilter()'s use of struct __msfilterreq;
  the kernel will return in msfr_nsrcs the number of source filters
  in-mode for a given multicast group.
  However, the filters themselves were never copied out, as the libc
  function clobbers this field with zero, causing the kernel to assume
  the provided vector of struct sockaddr_storage has zero length.
  This bug would only affect users of SSM multicast, which is shimmed
  in 7.x.
  Picked up during mtest(8) refactoring.

Modified:
  stable/7/lib/libc/net/sourcefilter.c

Modified: stable/7/lib/libc/net/sourcefilter.c
==============================================================================
--- stable/7/lib/libc/net/sourcefilter.c	Sun May 17 12:30:25 2009	(r192250)
+++ stable/7/lib/libc/net/sourcefilter.c	Sun May 17 15:42:41 2009	(r192251)
@@ -1,6 +1,6 @@
 /*-
- * Copyright (c) 2007 Bruce M. Simpson.
- * All rights reserved
+ * Copyright (c) 2007-2009 Bruce Simpson.
+ * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -10,21 +10,18 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 4. Neither the name of Bruce M. Simpson nor the names of other
- *    contributors may be used to endorse or promote products derived
- *    from this software without specific prior written permission.
  *
- * THIS SOFTWARE IS PROVIDED BY BRUCE M. SIMPSON AND AFFILIATES
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL BRUCE M. SIMPSON OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #include <sys/cdefs.h>
@@ -340,7 +337,7 @@ getsourcefilter(int s, uint32_t interfac
 {
 	struct __msfilterreq	 msfr;
 	sockunion_t		*psu;
-	int			 err, level, optlen, optname;
+	int			 err, level, nsrcs, optlen, optname;
 
 	if (interface == 0 || group == NULL || numsrc == NULL ||
 	    fmode == NULL) {
@@ -348,6 +345,7 @@ getsourcefilter(int s, uint32_t interfac
 		return (-1);
 	}
 
+	nsrcs = *numsrc;
 	*numsrc = 0;
 	*fmode = 0;
 
@@ -385,7 +383,7 @@ getsourcefilter(int s, uint32_t interfac
 	memset(&msfr, 0, optlen);
 	msfr.msfr_ifindex = interface;
 	msfr.msfr_fmode = 0;
-	msfr.msfr_nsrcs = *numsrc;
+	msfr.msfr_nsrcs = nsrcs;
 	memcpy(&msfr.msfr_group, &psu->ss, psu->ss.ss_len);
 
 	/*


More information about the svn-src-stable-7 mailing list