Fix getsockopt option_value initial initialization
On some platforms, some of the options we're getting the value for may be a single byte, so attempting to read the full int produces garbage. Found with IP_MULTICAST_TTL and IP_MULTICAST_LOOP on QNX. See: https://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.neutrino.lib_ref/topic/g/getsockopt.html#getsockopt__IP_MULTICAST_TTL Pick-to: 5.15 6.2 6.3 Change-Id: Id9f7f249c6c4be0c3f94c5904d402b4ec4e17b59 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
708eb85e38
commit
df270368ee
@ -46,6 +46,7 @@
|
||||
#include "qelapsedtimer.h"
|
||||
#include "qvarlengtharray.h"
|
||||
#include "qnetworkinterface.h"
|
||||
#include "qendian.h"
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
@ -329,12 +330,12 @@ int QNativeSocketEnginePrivate::option(QNativeSocketEngine::SocketOption opt) co
|
||||
}
|
||||
|
||||
int n, level;
|
||||
int v = -1;
|
||||
int v = 0;
|
||||
QT_SOCKOPTLEN_T len = sizeof(v);
|
||||
|
||||
convertToLevelAndOption(opt, socketProtocol, level, n);
|
||||
if (n != -1 && ::getsockopt(socketDescriptor, level, n, (char *) &v, &len) != -1)
|
||||
return v;
|
||||
return len == 1 ? qFromUnaligned<quint8>(&v) : v;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user