QUdpSocket: Work around WSARecvMsg quirk relating to no control block

WSARecvMsg does not return the sender in WSAMSG::name if WSAMSG::Control
isn't set. This makes no sense, so I'm assuming it's an API quirk we
need to work around.

[ChangeLog][QtNetwork][QUdpSocket] Fixed a regression from Qt 5.9.3
caused by an apparent Win32 API quirk we triggered when using
readDatagram(), resulting in an invalid QHostAddress sender address.
receiveDatagram() was not affected.

Task-number: QTBUG-64718
Change-Id: I71488efd29b645f7b228fffd14f9d84cc205c4b3
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Thiago Macieira 2017-11-23 14:42:54 -08:00 committed by Timur Pocheptsov
parent fa2a653b3b
commit 6a9d076e87

View File

@ -1215,10 +1215,8 @@ qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxL
msg.dwBufferCount = 1; msg.dwBufferCount = 1;
msg.name = reinterpret_cast<LPSOCKADDR>(&aa); msg.name = reinterpret_cast<LPSOCKADDR>(&aa);
msg.namelen = sizeof(aa); msg.namelen = sizeof(aa);
if (options & (QAbstractSocketEngine::WantDatagramHopLimit | QAbstractSocketEngine::WantDatagramDestination)) {
msg.Control.buf = cbuf; msg.Control.buf = cbuf;
msg.Control.len = sizeof(cbuf); msg.Control.len = sizeof(cbuf);
}
DWORD flags = 0; DWORD flags = 0;
DWORD bytesRead = 0; DWORD bytesRead = 0;