From 10f2b5aa66c95563702b02770df39c7cf1b2ef61 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 4 Oct 2017 21:20:01 -0700 Subject: QUdpSocket: make sure receiveDatagram() returns empty on error If the datagram reception failed, we forgot to set the buffer back to empty. The returned QNetworkDatagram did report isValid() == false, but it was possible to get the .data() and check its size, getting nonsense. Tests in the next commit. Change-Id: I638cf58bfa7b4e5fb386fffd14ea91adf2133d47 Reviewed-by: Jesus Fernandez Reviewed-by: Timur Pocheptsov Reviewed-by: Edward Welbourne --- src/network/socket/qudpsocket.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/network/socket') diff --git a/src/network/socket/qudpsocket.cpp b/src/network/socket/qudpsocket.cpp index 37b385dfb5..79629a07f2 100644 --- a/src/network/socket/qudpsocket.cpp +++ b/src/network/socket/qudpsocket.cpp @@ -454,10 +454,12 @@ QNetworkDatagram QUdpSocket::receiveDatagram(qint64 maxSize) QAbstractSocketEngine::WantAll); d->hasPendingData = false; d->socketEngine->setReadNotificationEnabled(true); - if (readBytes < 0) + if (readBytes < 0) { d->setErrorAndEmit(d->socketEngine->error(), d->socketEngine->errorString()); - else if (readBytes != result.d->data.size()) - result.d->data.truncate(readBytes); + readBytes = 0; + } + + result.d->data.truncate(readBytes); return result; } -- cgit v1.2.3 From 3fe74b76fd0eaf39d4c6681e2edca5adbf107883 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 7 Aug 2017 20:52:11 -0700 Subject: QHostInfo: Make getaddrinfo() mandatory All systems must implement it by now. If there's any system still without it, that means it has no IPv6 support, so they can disable QtNetwork entirely. [ChangeLog][Deprecation Notice] Starting with Qt 5.10, IPv6 support is mandatory for all platforms. Systems without proper IPv6 support, such as the getaddrinfo() function or the proper socket address structures, will not be able to build QtNetwork anymore. Change-Id: I3868166e5efc45538544fffd14d8c28046f9191b Reviewed-by: Edward Welbourne --- src/network/socket/qnet_unix_p.h | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src/network/socket') diff --git a/src/network/socket/qnet_unix_p.h b/src/network/socket/qnet_unix_p.h index 73d7ec2e77..5359872f96 100644 --- a/src/network/socket/qnet_unix_p.h +++ b/src/network/socket/qnet_unix_p.h @@ -174,16 +174,6 @@ static inline int qt_safe_ioctl(int sockfd, unsigned long request, T arg) #endif } -// VxWorks' headers do not specify any const modifiers -static inline in_addr_t qt_safe_inet_addr(const char *cp) -{ -#ifdef Q_OS_VXWORKS - return ::inet_addr((char *) cp); -#else - return ::inet_addr(cp); -#endif -} - static inline int qt_safe_sendmsg(int sockfd, const struct msghdr *msg, int flags) { #ifdef MSG_NOSIGNAL -- cgit v1.2.3