Merge pull request #5540 from dgarske/socksz

Fixes for building with 32-bit and socket size sign/unsigned mismatch
This commit is contained in:
Sean Parkinson
2022-09-02 16:33:41 +10:00
committed by GitHub

View File

@ -375,8 +375,9 @@ static int sockAddrEqual(
static int isDGramSock(int sfd) static int isDGramSock(int sfd)
{ {
int type = 0; int type = 0;
XSOCKLENT length = sizeof(int); /* optvalue 'type' is of size int */ /* optvalue 'type' is of size int */
XSOCKLENT length = (XSOCKLENT)sizeof(int);
if (getsockopt(sfd, SOL_SOCKET, SO_TYPE, &type, &length) == 0 && if (getsockopt(sfd, SOL_SOCKET, SO_TYPE, &type, &length) == 0 &&
type != SOCK_DGRAM) { type != SOCK_DGRAM) {
return 0; return 0;
@ -494,13 +495,13 @@ int EmbedReceiveFrom(WOLFSSL *ssl, char *buf, int sz, void *ctx)
} }
else if (dtlsCtx->userSet) { else if (dtlsCtx->userSet) {
/* Truncate peer size */ /* Truncate peer size */
if (peerSz > sizeof(lclPeer)) if (peerSz > (XSOCKLENT)sizeof(lclPeer))
peerSz = sizeof(lclPeer); peerSz = (XSOCKLENT)sizeof(lclPeer);
} }
else { else {
/* Truncate peer size */ /* Truncate peer size */
if (peerSz > dtlsCtx->peer.bufSz) if (peerSz > (XSOCKLENT)dtlsCtx->peer.bufSz)
peerSz = dtlsCtx->peer.bufSz; peerSz = (XSOCKLENT)dtlsCtx->peer.bufSz;
} }
recvd = TranslateReturnCode(recvd, sd); recvd = TranslateReturnCode(recvd, sd);