summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2014-05-25 14:26:51 -0700
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-26 00:09:55 +0200
commit385692b3ad12f35d0008bc4b309225fcaac0010d (patch)
tree95ec8803337a33ca52ed1c0cc504f1ab028b21df /src/network
parent1a4ff6f122f575aca21f6a0b9d9c14cac4a5ea66 (diff)
IPv6 scope ID of zero is not valid
IANA reserves scope ID of 0x0 to mean "no scope ID", so make sure that we don't try to set it when reading from the sockaddr_in6 structure. Change-Id: I71b207e6f8262ab2bf9fde993288a71ba63c7572 Reviewed-by: Richard J. Moore <rich@kde.org>
Diffstat (limited to 'src/network')
-rw-r--r--src/network/socket/qnativesocketengine_unix.cpp12
-rw-r--r--src/network/socket/qnativesocketengine_win.cpp3
2 files changed, 9 insertions, 6 deletions
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index 6ee8b696df..65244ce9cf 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -111,13 +111,15 @@ static inline void qt_socket_getPortAndAddress(const qt_sockaddr *s, quint16 *po
QHostAddress tmpAddress;
tmpAddress.setAddress(tmp);
*addr = tmpAddress;
+ if (s->a6.sin6_scope_id) {
#ifndef QT_NO_IPV6IFNAME
- char scopeid[IFNAMSIZ];
- if (::if_indextoname(s->a6.sin6_scope_id, scopeid)) {
- addr->setScopeId(QLatin1String(scopeid));
- } else
+ char scopeid[IFNAMSIZ];
+ if (::if_indextoname(s->a6.sin6_scope_id, scopeid)) {
+ addr->setScopeId(QLatin1String(scopeid));
+ } else
#endif
- addr->setScopeId(QString::number(s->a6.sin6_scope_id));
+ addr->setScopeId(QString::number(s->a6.sin6_scope_id));
+ }
}
if (port)
*port = ntohs(s->a6.sin6_port);
diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp
index b1c9073eb9..138d046bfc 100644
--- a/src/network/socket/qnativesocketengine_win.cpp
+++ b/src/network/socket/qnativesocketengine_win.cpp
@@ -182,7 +182,8 @@ static inline void qt_socket_getPortAndAddress(SOCKET socketDescriptor, const qt
if (address) {
QHostAddress a;
a.setAddress(tmp);
- a.setScopeId(QString::number(sa6->sin6_scope_id));
+ if (sa6->sin6_scope_id)
+ a.setScopeId(QString::number(sa6->sin6_scope_id));
*address = a;
}
if (port)