Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/rtadvd Fix some unaligned pointer issues.
details: https://anonhg.NetBSD.org/src/rev/146b810d7f9a
branches: trunk
changeset: 318382:146b810d7f9a
user: roy <roy%NetBSD.org@localhost>
date: Fri Apr 20 10:26:34 2018 +0000
description:
Fix some unaligned pointer issues.
diffstat:
usr.sbin/rtadvd/rrenum.c | 9 ++++++---
usr.sbin/rtadvd/rtadvd.c | 21 ++++++++++++---------
2 files changed, 18 insertions(+), 12 deletions(-)
diffs (125 lines):
diff -r 9b93a479ffc9 -r 146b810d7f9a usr.sbin/rtadvd/rrenum.c
--- a/usr.sbin/rtadvd/rrenum.c Fri Apr 20 09:56:22 2018 +0000
+++ b/usr.sbin/rtadvd/rrenum.c Fri Apr 20 10:26:34 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rrenum.c,v 1.20 2017/11/06 15:15:04 christos Exp $ */
+/* $NetBSD: rrenum.c,v 1.21 2018/04/20 10:26:34 roy Exp $ */
/* $KAME: rrenum.c,v 1.14 2004/06/14 05:36:00 itojun Exp $ */
/*
@@ -147,6 +147,7 @@
struct rr_pco_use *rpu, *rpulim;
struct rainfo *rai;
struct prefix *pp;
+ struct in6_addr rpm_prefix, rpu_prefix;
rpu = (struct rr_pco_use *)(rpm + 1);
rpulim = (struct rr_pco_use *)((char *)rpm + len);
@@ -201,8 +202,10 @@
logit(LOG_ERR, "<%s> ioctl: %m", __func__);
/* very adhoc: should be rewritten */
+ memcpy(&rpm_prefix, &rpm->rpm_prefix, sizeof(rpm_prefix));
+ memcpy(&rpu_prefix, &rpu->rpu_prefix, sizeof(rpu_prefix));
if (rpm->rpm_code == RPM_PCO_CHANGE &&
- IN6_ARE_ADDR_EQUAL(&rpm->rpm_prefix, &rpu->rpu_prefix) &&
+ IN6_ARE_ADDR_EQUAL(&rpm_prefix, &rpu_prefix) &&
rpm->rpm_matchlen == rpu->rpu_uselen &&
rpu->rpu_uselen == rpu->rpu_keeplen) {
if ((rai = if_indextorainfo(ifindex)) == NULL)
@@ -212,7 +215,7 @@
struct timespec now;
if (prefix_match(&pp->prefix, pp->prefixlen,
- &rpm->rpm_prefix,
+ &rpm_prefix,
rpm->rpm_matchlen)) {
/* change parameters */
pp->validlifetime = ntohl(rpu->rpu_vltime);
diff -r 9b93a479ffc9 -r 146b810d7f9a usr.sbin/rtadvd/rtadvd.c
--- a/usr.sbin/rtadvd/rtadvd.c Fri Apr 20 09:56:22 2018 +0000
+++ b/usr.sbin/rtadvd/rtadvd.c Fri Apr 20 10:26:34 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtadvd.c,v 1.59 2017/11/25 02:37:04 kre Exp $ */
+/* $NetBSD: rtadvd.c,v 1.60 2018/04/20 10:26:34 roy Exp $ */
/* $KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $ */
/*
@@ -1213,21 +1213,24 @@
int inconsistent = 0;
char ntopbuf[INET6_ADDRSTRLEN], prefixbuf[INET6_ADDRSTRLEN];
struct timespec now;
+ struct in6_addr prefix;
#if 0 /* impossible */
if (pinfo->nd_opt_pi_type != ND_OPT_PREFIX_INFORMATION)
return 0;
#endif
+ memcpy(&prefix, &pinfo->nd_opt_pi_prefix, sizeof(prefix));
+
/*
* log if the adveritsed prefix has link-local scope(sanity check?)
*/
- if (IN6_IS_ADDR_LINKLOCAL(&pinfo->nd_opt_pi_prefix)) {
+ if (IN6_IS_ADDR_LINKLOCAL(&prefix)) {
logit(LOG_INFO,
"%s: link-local prefix %s/%d is advertised "
"from %s on %s",
__func__,
- inet_ntop(AF_INET6, &pinfo->nd_opt_pi_prefix,
+ inet_ntop(AF_INET6, &prefix,
prefixbuf, INET6_ADDRSTRLEN),
pinfo->nd_opt_pi_prefix_len,
inet_ntop(AF_INET6, &from->sin6_addr,
@@ -1235,12 +1238,12 @@
rai->ifname);
}
- if ((pp = find_prefix(rai, &pinfo->nd_opt_pi_prefix,
+ if ((pp = find_prefix(rai, &prefix,
pinfo->nd_opt_pi_prefix_len)) == NULL) {
logit(LOG_INFO,
"%s: prefix %s/%d from %s on %s is not in our list",
__func__,
- inet_ntop(AF_INET6, &pinfo->nd_opt_pi_prefix,
+ inet_ntop(AF_INET6, &prefix,
prefixbuf, INET6_ADDRSTRLEN),
pinfo->nd_opt_pi_prefix_len,
inet_ntop(AF_INET6, &from->sin6_addr,
@@ -1268,7 +1271,7 @@
" (decr. in real time) inconsistent on %s:"
" %d from %s, %ld from us",
__func__,
- inet_ntop(AF_INET6, &pinfo->nd_opt_pi_prefix,
+ inet_ntop(AF_INET6, &prefix,
prefixbuf, INET6_ADDRSTRLEN),
pinfo->nd_opt_pi_prefix_len,
rai->ifname, preferred_time,
@@ -1283,7 +1286,7 @@
" inconsistent on %s:"
" %d from %s, %d from us",
__func__,
- inet_ntop(AF_INET6, &pinfo->nd_opt_pi_prefix,
+ inet_ntop(AF_INET6, &prefix,
prefixbuf, INET6_ADDRSTRLEN),
pinfo->nd_opt_pi_prefix_len,
rai->ifname, preferred_time,
@@ -1304,7 +1307,7 @@
" (decr. in real time) inconsistent on %s:"
" %d from %s, %ld from us",
__func__,
- inet_ntop(AF_INET6, &pinfo->nd_opt_pi_prefix,
+ inet_ntop(AF_INET6, &prefix,
prefixbuf, INET6_ADDRSTRLEN),
pinfo->nd_opt_pi_prefix_len,
rai->ifname, preferred_time,
@@ -1319,7 +1322,7 @@
" inconsistent on %s:"
" %d from %s, %d from us",
__func__,
- inet_ntop(AF_INET6, &pinfo->nd_opt_pi_prefix,
+ inet_ntop(AF_INET6, &prefix,
prefixbuf, INET6_ADDRSTRLEN),
pinfo->nd_opt_pi_prefix_len,
rai->ifname, valid_time,
Home |
Main Index |
Thread Index |
Old Index