fix unaligned access on sparc64

ok pval
This commit is contained in:
sturm 2007-06-15 11:53:39 +00:00
parent 18bd2559c8
commit 97c2dadeea
2 changed files with 70 additions and 4 deletions

View File

@ -1,8 +1,9 @@
# $OpenBSD: Makefile,v 1.28 2005/08/02 07:25:47 pvalchev Exp $
# $OpenBSD: Makefile,v 1.29 2007/06/15 11:53:39 sturm Exp $
COMMENT= "manage remote serial consoles via TCP/IP"
DISTNAME= conserver-8.1.11
PKGNAME= ${DISTNAME}p0
CATEGORIES= comms
MAINTAINER= Peter Valchev <pvalchev@openbsd.org>

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-conserver_cutil_c,v 1.1 2005/08/02 07:25:48 pvalchev Exp $
--- conserver/cutil.c.orig Tue Nov 9 01:37:05 2004
+++ conserver/cutil.c Tue Aug 2 01:22:33 2005
$OpenBSD: patch-conserver_cutil_c,v 1.2 2007/06/15 11:53:39 sturm Exp $
--- conserver/cutil.c.orig Tue Nov 9 09:37:05 2004
+++ conserver/cutil.c Thu May 31 14:11:55 2007
@@ -84,7 +84,7 @@ StrTime(ltime)
time_t tyme;
@ -19,3 +19,68 @@ $OpenBSD: patch-conserver_cutil_c,v 1.1 2005/08/02 07:25:48 pvalchev Exp $
BuildString((char *)0, save);
}
@@ -2138,7 +2138,7 @@ ProbeInterfaces(bindAddr)
{
#ifdef SIOCGIFCONF
struct ifconf ifc;
- struct ifreq *ifr;
+ struct ifreq ifr;
#ifdef SIOCGIFFLAGS
struct ifreq ifrcopy;
#endif
@@ -2198,7 +2198,7 @@ ProbeInterfaces(bindAddr)
* than loop through looking for valid interfaces that are up
* twice, huh?
*/
- count = ifc.ifc_len / sizeof(*ifr);
+ count = ifc.ifc_len / sizeof(ifr);
CONDDEBUG((1, "ProbeInterfaces(): ifc_len==%d max_count==%d",
ifc.ifc_len, count));
@@ -2217,36 +2217,37 @@ ProbeInterfaces(bindAddr)
for (m = r = 0; r < ifc.ifc_len;) {
struct sockaddr *sa;
- ifr = (struct ifreq *)&ifc.ifc_buf[r];
- sa = (struct sockaddr *)&ifr->ifr_addr;
+
+ memcpy(&ifr, &ifc.ifc_buf[r], sizeof(ifr));
+ sa = (struct sockaddr *)&ifr.ifr_addr;
/* don't use less than a ifreq sized chunk */
- if ((ifc.ifc_len - r) < sizeof(*ifr))
+ if ((ifc.ifc_len - r) < sizeof(ifr))
break;
#ifdef HAVE_SA_LEN
- if (sa->sa_len > sizeof(ifr->ifr_addr))
- r += sizeof(ifr->ifr_name) + sa->sa_len;
+ if (sa->sa_len > sizeof(ifr.ifr_addr))
+ r += sizeof(ifr.ifr_name) + sa->sa_len;
else
#endif
- r += sizeof(*ifr);
+ r += sizeof(ifr);
if (sa->sa_family == AF_INET) {
struct sockaddr_in *sin = (struct sockaddr_in *)sa;
#ifdef SIOCGIFFLAGS
/* make sure the interface is up */
- ifrcopy = *ifr;
+ memcpy(&ifrcopy, &ifr, sizeof(ifrcopy));
if ((ioctl(sock, SIOCGIFFLAGS, &ifrcopy) == 0) &&
((ifrcopy.ifr_flags & IFF_UP) == 0))
continue;
#endif
CONDDEBUG((1, "ProbeInterfaces(): name=%s addr=%s",
- ifr->ifr_name, inet_ntoa(sin->sin_addr)));
+ ifr.ifr_name, inet_ntoa(sin->sin_addr)));
#if HAVE_MEMCPY
memcpy(&myAddrs[m], &(sin->sin_addr), sizeof(struct in_addr));
#else
bcopy(&(sin->sin_addr), &myAddrs[m], sizeof(struct in_addr));
#endif
Verbose("interface address %s (%s)", inet_ntoa(myAddrs[m]),
- ifr->ifr_name);
+ ifr.ifr_name);
m++;
}
}