diff --git a/CHANGES b/CHANGES index c223c1a..1d38730 100644 --- a/CHANGES +++ b/CHANGES @@ -15,6 +15,9 @@ corrections: Debian bug 531078: socat execs children with SIGCHLD ignored; corrected to default. Thanks to Martin Dorey for reporting this bug. + added struct sockaddr_ll to union sockaddr_union to avoid "strict + aliasing" warnings (problem reported by Paul Wouters) + info message during socks connect showed bad port number on little endian systems due to wrong byte order (thanks to Peter M. Galbavy for bug report and patch) diff --git a/sysutils.h b/sysutils.h index e5e47b2..380552e 100644 --- a/sysutils.h +++ b/sysutils.h @@ -1,5 +1,5 @@ /* source: sysutils.h */ -/* Copyright Gerhard Rieger 2001-2008 */ +/* Copyright Gerhard Rieger 2001-2012 */ /* Published under the GNU General Public License V.2, see file COPYING */ #ifndef __sysutils_h_included @@ -27,6 +27,10 @@ union sockaddr_union { #if _WITH_IP6 struct sockaddr_in6 ip6; #endif /* _WITH_IP6 */ +#if WITH_INTERFACE + struct sockaddr_ll ll; +#endif + } ; #endif /* _WITH_SOCKET */ diff --git a/xio-interface.c b/xio-interface.c index 9f3b169..9f9bf5e 100644 --- a/xio-interface.c +++ b/xio-interface.c @@ -1,5 +1,5 @@ /* source: xio-interface.c */ -/* Copyright Gerhard Rieger 2008 */ +/* Copyright Gerhard Rieger 2008-2012 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this file contains the source for opening addresses of raw socket type */ @@ -65,9 +65,9 @@ int _xioopen_interface(const char *ifname, needbind = true; } /*!!! parse by ':' */ - ((struct sockaddr_ll *)&us)->sll_family = pf; - ((struct sockaddr_ll *)&us)->sll_protocol = htons(ETH_P_ALL); - ((struct sockaddr_ll *)&us)->sll_ifindex = ifidx; + us.ll.sll_family = pf; + us.ll.sll_protocol = htons(ETH_P_ALL); + us.ll.sll_ifindex = ifidx; uslen = sizeof(sall); needbind = true; xfd->peersa = (union sockaddr_union)us; diff --git a/xioread.c b/xioread.c index 08f7d82..31613d3 100644 --- a/xioread.c +++ b/xioread.c @@ -1,5 +1,5 @@ /* source: xioread.c */ -/* Copyright Gerhard Rieger 2001-2009 */ +/* Copyright Gerhard Rieger 2001-2012 */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this is the source of the extended read function */ @@ -178,7 +178,7 @@ ssize_t xioread(xiofile_t *file, void *buff, size_t bufsiz) { */ #if defined(PF_PACKET) && defined(PACKET_OUTGOING) if (from.soa.sa_family == PF_PACKET) { - if ((((struct sockaddr_ll *)&from.soa)->sll_pkttype & PACKET_OUTGOING) + if ((from.ll.sll_pkttype & PACKET_OUTGOING) == 0) { errno = EAGAIN; return -1; }