forked from wolfSSL/wolfssl
getsockopt needs to take in an int
This caused an issue on big endian platforms From the getsockopt man page: Most socket-level options utilize an int argument for optval. For setsockopt(), the argument should be non‐ zero to enable a boolean option, or zero if the option is to be disabled.
This commit is contained in:
@ -418,12 +418,12 @@ static int PeerIsIpv6(const SOCKADDR_S *peer, XSOCKLENT len)
|
|||||||
|
|
||||||
static int isDGramSock(int sfd)
|
static int isDGramSock(int sfd)
|
||||||
{
|
{
|
||||||
char type = 0;
|
int type = 0;
|
||||||
/* optvalue 'type' is of size int */
|
/* optvalue 'type' is of size int */
|
||||||
XSOCKLENT length = (XSOCKLENT)sizeof(char);
|
XSOCKLENT length = (XSOCKLENT)sizeof(type);
|
||||||
|
|
||||||
if (getsockopt(sfd, SOL_SOCKET, SO_TYPE, &type, &length) == 0 &&
|
if (getsockopt(sfd, SOL_SOCKET, SO_TYPE, (XSOCKOPT_TYPE_OPTVAL_TYPE)&type,
|
||||||
type != SOCK_DGRAM) {
|
&length) == 0 && type != SOCK_DGRAM) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -381,6 +381,13 @@
|
|||||||
#define XSOCKLENT socklen_t
|
#define XSOCKLENT socklen_t
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef XSOCKOPT_TYPE_OPTVAL_TYPE
|
||||||
|
#ifdef USE_WINDOWS_API
|
||||||
|
#define XSOCKOPT_TYPE_OPTVAL_TYPE void*
|
||||||
|
#else
|
||||||
|
#define XSOCKOPT_TYPE_OPTVAL_TYPE char*
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Socket Addr Support */
|
/* Socket Addr Support */
|
||||||
#ifdef HAVE_SOCKADDR
|
#ifdef HAVE_SOCKADDR
|
||||||
|
Reference in New Issue
Block a user