From 004ad12669ef696eeba70fd57d1eb0c67c806d1d Mon Sep 17 00:00:00 2001
From: Craig Scott <craig.scott@csiro.au>
Date: Wed, 11 May 2011 16:51:28 +1000
Subject: Fix incorrect hardware address on systems without getifaddrs()

On unix systems for which QT_NO_GETIFADDRS is defined, the way that the
hardware address field is extracted from the result of a call to
qt_safe_ioctl() is incorrect. The address of the ifreq.ifr_addr struct
is taken rather than the appropriate member within that struct, sa_data,
resulting in a memory offset and subsequently the hardware address has
garbage in the first two of six fields. This commit modifies the code
to pass the sa_data member instead of the address of the struct as a
whole.

Task-number: QTBUG-19165
Merge-request: 2614
Reviewed-by: Martin Petersson
---
 src/network/kernel/qnetworkinterface_unix.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/network/kernel/qnetworkinterface_unix.cpp b/src/network/kernel/qnetworkinterface_unix.cpp
index 6098bde..7f251a7 100644
--- a/src/network/kernel/qnetworkinterface_unix.cpp
+++ b/src/network/kernel/qnetworkinterface_unix.cpp
@@ -219,7 +219,7 @@ static QNetworkInterfacePrivate *findInterface(int socket, QList<QNetworkInterfa
 #ifdef SIOCGIFHWADDR
         // Get the HW address
         if (qt_safe_ioctl(socket, SIOCGIFHWADDR, &req) >= 0) {
-            uchar *addr = (uchar *)&req.ifr_addr;
+            uchar *addr = (uchar *)req.ifr_addr.sa_data;
             iface->hardwareAddress = iface->makeHwAddress(6, addr);
         }
 #endif
-- 
cgit v0.12