[rtems commit] networking: alignment exception in ioctl(SIOCGIFCONF)
Gedare Bloom
gedare at rtems.org
Mon Feb 23 15:49:10 UTC 2015
Module: rtems
Branch: 4.10
Commit: 70148eef285bb2ad924d2e25e4b3772bba6eb23c
Changeset: http://git.rtems.org/rtems/commit/?id=70148eef285bb2ad924d2e25e4b3772bba6eb23c
Author: Till Straumann <strauman at slac.stanford.edu>
Date: Mon Feb 23 10:46:22 2015 -0500
networking: alignment exception in ioctl(SIOCGIFCONF)
Access memory using a byte stream when copying to avoid unaligned
access. update #1401
---
cpukit/libnetworking/net/if.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/cpukit/libnetworking/net/if.c b/cpukit/libnetworking/net/if.c
index 36d48fc..bc8e78c 100644
--- a/cpukit/libnetworking/net/if.c
+++ b/cpukit/libnetworking/net/if.c
@@ -719,9 +719,10 @@ ifconf(u_long cmd, caddr_t data)
struct ifnet *ifp = ifnet;
struct ifaddr *ifa;
struct ifreq ifr, *ifrp;
+ char *ifrpc;
int space = ifc->ifc_len, error = 0;
- ifrp = ifc->ifc_req;
+ ifrpc = (char*)ifc->ifc_req;
for (; space > sizeof (ifr) && ifp; ifp = ifp->if_next) {
char workbuf[64];
int ifnlen;
@@ -735,11 +736,11 @@ ifconf(u_long cmd, caddr_t data)
if ((ifa = ifp->if_addrlist) == 0) {
bzero((caddr_t)&ifr.ifr_addr, sizeof(ifr.ifr_addr));
- error = copyout((caddr_t)&ifr, (caddr_t)ifrp,
+ error = copyout((caddr_t)&ifr, (caddr_t)ifrpc,
sizeof (ifr));
if (error)
break;
- space -= sizeof (ifr), ifrp++;
+ space -= sizeof (ifr); ifrpc+=sizeof(ifr);
} else
for ( ; space > sizeof (ifr) && ifa; ifa = ifa->ifa_next) {
struct sockaddr *sa = ifa->ifa_addr;
@@ -749,27 +750,27 @@ ifconf(u_long cmd, caddr_t data)
(struct osockaddr *)&ifr.ifr_addr;
ifr.ifr_addr = *sa;
osa->sa_family = sa->sa_family;
- error = copyout((caddr_t)&ifr, (caddr_t)ifrp,
+ error = copyout((caddr_t)&ifr, (caddr_t)ifrpc,
sizeof (ifr));
- ifrp++;
+ ifrpc+=sizeof(ifr);
} else
#endif
if (sa->sa_len <= sizeof(*sa)) {
ifr.ifr_addr = *sa;
- error = copyout((caddr_t)&ifr, (caddr_t)ifrp,
+ error = copyout((caddr_t)&ifr, (caddr_t)ifrpc,
sizeof (ifr));
- ifrp++;
+ ifrpc+=sizeof(ifr);
} else {
space -= sa->sa_len - sizeof(*sa);
if (space < sizeof (ifr))
break;
- error = copyout((caddr_t)&ifr, (caddr_t)ifrp,
+ error = copyout((caddr_t)&ifr, (caddr_t)ifrpc,
sizeof (ifr.ifr_name));
+ ifrpc+=sizeof(ifr.ifr_name);
if (error == 0)
error = copyout((caddr_t)sa,
- (caddr_t)&ifrp->ifr_addr, sa->sa_len);
- ifrp = (struct ifreq *)
- (sa->sa_len + (caddr_t)&ifrp->ifr_addr);
+ (caddr_t)ifrpc, sa->sa_len);
+ ifrpc += sa->sa_len;
}
if (error)
break;
More information about the vc
mailing list