Subject: bin/11616: mld6query(8) and pim6dd(8) have alignment problem
To: None <gnats-bugs@gnats.netbsd.org>
From: None <ura@hiru.aoba.yokohama.jp>
List: netbsd-bugs
Date: 11/30/2000 07:38:17
>Number:         11616
>Category:       bin
>Synopsis:       mld6query(8) and pim6dd(8) have aligment problem
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Nov 30 07:38:01 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     URA Hiroshi
>Release:        kernel 1.5K (2000/11/11) / userland 1.5G (2000/10/25)
>Organization:
>Environment:
System: NetBSD uzuki.hiru.aoba.yokohama.jp 1.5K NetBSD 1.5K (UZUKI) #18: Sat Nov 11 22:53:48 JST 2000 ura@uzuki.hiru.aoba.yokohama.jp:/amd/yayoi/usr/local/src/NetBSD/current/src/sys/arch/sparc/compile/UZUKI sparc


>Description:

According to RFC 2992:

  4.3.4.  CMSG_SPACE
	< .. snip .. >
  This macro should not be used to initialize the cmsg_len member
  of a cmsghdr structure; instead use the CMSG_LEN() macro.

mld6query(8) and pim6dd(8) use CMSG_SPACE() insted of CMSG_LEN().

>How-To-Repeat:

>Fix:

apply this patch

Index: pim6dd/mld6.c
===================================================================
RCS file: /cvsroot/netbsd/basesrc/usr.sbin/pim6dd/mld6.c,v
retrieving revision 1.8
diff -u -u -r1.8 mld6.c
--- pim6dd/mld6.c	2000/10/06 00:13:02	1.8
+++ pim6dd/mld6.c	2000/11/30 14:24:14
@@ -457,7 +457,7 @@
 	    if (ifindex != -1 || src) {
 		    struct in6_pktinfo *pktinfo;
 
-		    cmsgp->cmsg_len = CMSG_SPACE(sizeof(struct in6_pktinfo));
+		    cmsgp->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo));
 		    cmsgp->cmsg_level = IPPROTO_IPV6;
 		    cmsgp->cmsg_type = IPV6_PKTINFO;
 		    pktinfo = (struct in6_pktinfo *)CMSG_DATA(cmsgp);
@@ -473,7 +473,7 @@
 		    int currentlen;
 		    void *hbhbuf, *optp = NULL;
 
-		    cmsgp->cmsg_len = CMSG_SPACE(hbhlen);
+		    cmsgp->cmsg_len = CMSG_LEN(hbhlen);
 		    cmsgp->cmsg_level = IPPROTO_IPV6;
 		    cmsgp->cmsg_type = IPV6_HOPOPTS;
 		    hbhbuf = CMSG_DATA(cmsgp);
Index: pim6dd/pim6.c
===================================================================
RCS file: /cvsroot/netbsd/basesrc/usr.sbin/pim6dd/pim6.c,v
retrieving revision 1.5
diff -u -u -r1.5 pim6.c
--- pim6dd/pim6.c	2000/05/19 10:43:43	1.5
+++ pim6dd/pim6.c	2000/11/30 14:24:30
@@ -132,7 +132,7 @@
 	sndmh.msg_controllen = sndcmsglen;
 	/* initilization cmsg for specifing outgoing interfaces and source */
 	cmsgp=(struct cmsghdr *)sndcmsgbuf;
-	cmsgp->cmsg_len = CMSG_SPACE(sizeof(struct in6_pktinfo));
+	cmsgp->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo));
 	cmsgp->cmsg_level = IPPROTO_IPV6;
 	cmsgp->cmsg_type = IPV6_PKTINFO;
 	sndpktinfo = (struct in6_pktinfo *)CMSG_DATA(cmsgp);
Index: mld6query/mld6.c
===================================================================
RCS file: /cvsroot/netbsd/basesrc/usr.sbin/mld6query/mld6.c,v
retrieving revision 1.2
diff -u -u -r1.2 mld6.c
--- mld6query/mld6.c	1999/09/03 04:34:34	1.2
+++ mld6query/mld6.c	2000/11/30 14:25:03
@@ -191,7 +191,7 @@
 	m.msg_control = (caddr_t)cmsgbuf;
 	m.msg_controllen = cmsglen;
 	/* specify the outgoing interface */
-	cmsgp->cmsg_len = CMSG_SPACE(sizeof(struct in6_pktinfo));
+	cmsgp->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo));
 	cmsgp->cmsg_level = IPPROTO_IPV6;
 	cmsgp->cmsg_type = IPV6_PKTINFO;
 	pi = (struct in6_pktinfo *)CMSG_DATA(cmsgp);
>Release-Note:
>Audit-Trail:
>Unformatted: