summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/network/kernel/qdnslookup_unix.cpp2
-rw-r--r--src/network/socket/qnativesocketengine_p.h12
2 files changed, 14 insertions, 0 deletions
diff --git a/src/network/kernel/qdnslookup_unix.cpp b/src/network/kernel/qdnslookup_unix.cpp
index a5e97c4a93..cb8129efc5 100644
--- a/src/network/kernel/qdnslookup_unix.cpp
+++ b/src/network/kernel/qdnslookup_unix.cpp
@@ -37,6 +37,7 @@
#include <qscopedpointer.h>
#include <qurl.h>
#include <private/qmutexpool_p.h>
+#include <private/qnativesocketengine_p.h>
#include <sys/types.h>
#include <netinet/in.h>
@@ -160,6 +161,7 @@ void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestN
state._u._ext.nscount6 = 1;
ns->sin6_family = AF_INET6;
ns->sin6_port = htons(53);
+ SetSALen::set(ns, sizeof(*ns));
Q_IPV6ADDR ipv6Address = nameserver.toIPv6Address();
for (int i=0; i<16; i++) {
diff --git a/src/network/socket/qnativesocketengine_p.h b/src/network/socket/qnativesocketengine_p.h
index 39e4d5e457..2dc4bbaced 100644
--- a/src/network/socket/qnativesocketengine_p.h
+++ b/src/network/socket/qnativesocketengine_p.h
@@ -99,6 +99,16 @@ union qt_sockaddr {
sockaddr_in6 a6;
};
+namespace {
+namespace SetSALen {
+ template <typename T> void set(T *sa, typename QtPrivate::QEnableIf<(&T::sa_len, true), QT_SOCKLEN_T>::Type len)
+ { sa->sa_len = len; }
+ template <typename T> void set(T *sin6, typename QtPrivate::QEnableIf<(&T::sin6_len, true), QT_SOCKLEN_T>::Type len)
+ { sin6->sin6_len = len; }
+ template <typename T> void set(T *, ...) {}
+}
+}
+
class QNativeSocketEnginePrivate;
#ifndef QT_NO_NETWORKINTERFACE
class QNetworkInterface;
@@ -287,12 +297,14 @@ public:
Q_IPV6ADDR tmp = address.toIPv6Address();
memcpy(&aa->a6.sin6_addr, &tmp, sizeof(tmp));
*sockAddrSize = sizeof(sockaddr_in6);
+ SetSALen::set(&aa->a, sizeof(sockaddr_in6));
} else {
memset(&aa->a, 0, sizeof(sockaddr_in));
aa->a4.sin_family = AF_INET;
aa->a4.sin_port = htons(port);
aa->a4.sin_addr.s_addr = htonl(address.toIPv4Address());
*sockAddrSize = sizeof(sockaddr_in);
+ SetSALen::set(&aa->a, sizeof(sockaddr_in));
}
}