summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Straumann <strauman@slac.stanford.edu>2015-02-23 10:46:22 -0500
committerGedare Bloom <gedare@rtems.org>2015-02-23 10:48:56 -0500
commit70148eef285bb2ad924d2e25e4b3772bba6eb23c (patch)
tree1324c4d09157e6b475d0360bc338cf13a0951ce0
parent0863e8e3903d1d4fa04df3bdf847931240570bfa (diff)
downloadrtems-70148eef285bb2ad924d2e25e4b3772bba6eb23c.tar.bz2
networking: alignment exception in ioctl(SIOCGIFCONF)
Access memory using a byte stream when copying to avoid unaligned access. update #1401
-rw-r--r--cpukit/libnetworking/net/if.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/cpukit/libnetworking/net/if.c b/cpukit/libnetworking/net/if.c
index 36d48fcc34..bc8e78c1fe 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;