svn commit: r332765 - in stable/11/sys/netpfil/ipfw: . nat64

Andrey V. Elsukov ae at FreeBSD.org
Thu Apr 19 10:11:40 UTC 2018


Author: ae
Date: Thu Apr 19 10:11:39 2018
New Revision: 332765
URL: https://svnweb.freebsd.org/changeset/base/332765

Log:
  MFC r316825:
    Use address of specific union member instead of whole union address to
    fix PVS-Studio warnings.
  
  MFC r316826:
    Avoid undefined behavior.
  
    The 'pktid' variable is modified while being used twice between
    sequence points, probably due to htonl() is macro.

Modified:
  stable/11/sys/netpfil/ipfw/ip_fw_table_algo.c
  stable/11/sys/netpfil/ipfw/nat64/nat64stl.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/netpfil/ipfw/ip_fw_table_algo.c
==============================================================================
--- stable/11/sys/netpfil/ipfw/ip_fw_table_algo.c	Thu Apr 19 10:08:28 2018	(r332764)
+++ stable/11/sys/netpfil/ipfw/ip_fw_table_algo.c	Thu Apr 19 10:11:39 2018	(r332765)
@@ -526,7 +526,8 @@ ta_dump_radix_tentry(void *ta_state, struct table_info
 #ifdef INET6
 	} else {
 		xn = (struct radix_addr_xentry *)e;
-		memcpy(&tent->k, &xn->addr6.sin6_addr, sizeof(struct in6_addr));
+		memcpy(&tent->k.addr6, &xn->addr6.sin6_addr,
+		    sizeof(struct in6_addr));
 		tent->masklen = xn->masklen;
 		tent->subtype = AF_INET6;
 		tent->v.kidx = xn->value;
@@ -1381,7 +1382,7 @@ ta_dump_chash_tentry(void *ta_state, struct table_info
 		tent->v.kidx = ent->value;
 #ifdef INET6
 	} else {
-		memcpy(&tent->k, &ent->a.a6, sizeof(struct in6_addr));
+		memcpy(&tent->k.addr6, &ent->a.a6, sizeof(struct in6_addr));
 		tent->masklen = cfg->mask6;
 		tent->subtype = AF_INET6;
 		tent->v.kidx = ent->value;
@@ -3984,7 +3985,8 @@ ta_dump_kfib_tentry_int(struct sockaddr *paddr, struct
 	if (paddr->sa_family == AF_INET6) {
 		addr6 = (struct sockaddr_in6 *)paddr;
 		mask6 = (struct sockaddr_in6 *)pmask;
-		memcpy(&tent->k, &addr6->sin6_addr, sizeof(struct in6_addr));
+		memcpy(&tent->k.addr6, &addr6->sin6_addr,
+		    sizeof(struct in6_addr));
 		len = 128;
 		if (mask6 != NULL)
 			len = contigmask((uint8_t *)&mask6->sin6_addr, 128);

Modified: stable/11/sys/netpfil/ipfw/nat64/nat64stl.c
==============================================================================
--- stable/11/sys/netpfil/ipfw/nat64/nat64stl.c	Thu Apr 19 10:08:28 2018	(r332764)
+++ stable/11/sys/netpfil/ipfw/nat64/nat64stl.c	Thu Apr 19 10:11:39 2018	(r332765)
@@ -75,7 +75,8 @@ nat64stl_log(struct pfloghdr *plog, struct mbuf *m, sa
 	plog->action = PF_NAT;
 	plog->dir = PF_IN;
 	plog->rulenr = htonl(kidx);
-	plog->subrulenr = htonl(++pktid);
+	pktid++;
+	plog->subrulenr = htonl(pktid);
 	plog->ruleset[0] = '\0';
 	strlcpy(plog->ifname, "NAT64STL", sizeof(plog->ifname));
 	ipfw_bpf_mtap2(plog, PFLOG_HDRLEN, m);


More information about the svn-src-all mailing list