From 2695f366423f2e4559dba26121206f8b1243b191 Mon Sep 17 00:00:00 2001 From: David Garske Date: Thu, 1 Sep 2022 11:39:34 -0700 Subject: [PATCH] Fixes for building with 32-bit and socket size sign/unsigned mismatch. Tested with: `./configure --enable-all CFLAGS="-m32 -DXSOCKLENT=int" LDFLAGS="-m32" && make` --- src/wolfio.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/wolfio.c b/src/wolfio.c index 0eb5833e3..cc7f40129 100644 --- a/src/wolfio.c +++ b/src/wolfio.c @@ -375,8 +375,9 @@ static int sockAddrEqual( static int isDGramSock(int sfd) { 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 && type != SOCK_DGRAM) { return 0; @@ -494,13 +495,13 @@ int EmbedReceiveFrom(WOLFSSL *ssl, char *buf, int sz, void *ctx) } else if (dtlsCtx->userSet) { /* Truncate peer size */ - if (peerSz > sizeof(lclPeer)) - peerSz = sizeof(lclPeer); + if (peerSz > (XSOCKLENT)sizeof(lclPeer)) + peerSz = (XSOCKLENT)sizeof(lclPeer); } else { /* Truncate peer size */ - if (peerSz > dtlsCtx->peer.bufSz) - peerSz = dtlsCtx->peer.bufSz; + if (peerSz > (XSOCKLENT)dtlsCtx->peer.bufSz) + peerSz = (XSOCKLENT)dtlsCtx->peer.bufSz; } recvd = TranslateReturnCode(recvd, sd);