Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 May 2016 22:02:19 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r300167 - in head: contrib/bsnmp/snmpd usr.sbin/bsnmpd/bsnmpd
Message-ID:  <201605182202.u4IM2JF7047307@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: glebius
Date: Wed May 18 22:02:19 2016
New Revision: 300167
URL: https://svnweb.freebsd.org/changeset/base/300167

Log:
  Revert r299830, it has couple of fatal errors.
  
  The CMSG_ family of macros take care of alignment, so we don't need r299830
  at all, even if it was correct.  Put NO_WCAST_ALIGN into Makefile.
  
  Together with:	peter

Modified:
  head/contrib/bsnmp/snmpd/main.c
  head/usr.sbin/bsnmpd/bsnmpd/Makefile

Modified: head/contrib/bsnmp/snmpd/main.c
==============================================================================
--- head/contrib/bsnmp/snmpd/main.c	Wed May 18 20:55:04 2016	(r300166)
+++ head/contrib/bsnmp/snmpd/main.c	Wed May 18 22:02:19 2016	(r300167)
@@ -1169,7 +1169,7 @@ recv_dgram(struct port_input *pi, struct
 			memcpy(laddr, CMSG_DATA(cmsg), sizeof(struct in_addr));
 		if (cmsg->cmsg_level == SOL_SOCKET &&
 		    cmsg->cmsg_type == SCM_CREDS)
-			memcpy(cred, CMSG_DATA(cmsg), sizeof(struct sockcred));
+			cred = (struct sockcred *)CMSG_DATA(cmsg);
 	}
 
 	if (pi->cred)
@@ -1207,7 +1207,7 @@ snmpd_input(struct port_input *pi, struc
 
 		ret = recv_stream(pi);
 	} else {
-		struct in_addr laddr;
+		struct in_addr *laddr;
 
 		memset(cbuf, 0, CMSG_SPACE(sizeof(struct in_addr)));
 		msg.msg_control = cbuf;
@@ -1216,11 +1216,11 @@ snmpd_input(struct port_input *pi, struc
 		cmsgp->cmsg_len = CMSG_LEN(sizeof(struct in_addr));
 		cmsgp->cmsg_level = IPPROTO_IP;
 		cmsgp->cmsg_type = IP_SENDSRCADDR;
-		memcpy(&laddr, CMSG_DATA(cmsgp), sizeof(struct in_addr));
+		laddr = (struct in_addr *)CMSG_DATA(cmsgp);
 		
-		ret = recv_dgram(pi, &laddr);
+		ret = recv_dgram(pi, laddr);
 
-		if (laddr.s_addr == 0) {
+		if (laddr->s_addr == 0) {
 			msg.msg_control = NULL;
 			msg.msg_controllen = 0;
 		}

Modified: head/usr.sbin/bsnmpd/bsnmpd/Makefile
==============================================================================
--- head/usr.sbin/bsnmpd/bsnmpd/Makefile	Wed May 18 20:55:04 2016	(r300166)
+++ head/usr.sbin/bsnmpd/bsnmpd/Makefile	Wed May 18 22:02:19 2016	(r300167)
@@ -47,6 +47,7 @@ MANFILTER=	sed -e 's%@MODPATH@%${LIBDIR}
 		    -e 's%@DEFPATH@%${DEFSDIR}/%g'		\
 		    -e 's%@MIBSPATH@%${BMIBSDIR}/%g'
 
+NO_WCAST_ALIGN=	yes
 WARNS?=		6
 
 .include <bsd.prog.mk>



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