Fix conversion error in wolfio.c
This commit is contained in:
parent
affd0a318e
commit
692a7d55ff
96
src/wolfio.c
96
src/wolfio.c
@ -558,7 +558,7 @@ int EmbedReceiveFrom(WOLFSSL *ssl, char *buf, int sz, void *ctx)
|
||||
start = LowResTimer();
|
||||
}
|
||||
else {
|
||||
dtls_timeout -= LowResTimer() - start;
|
||||
dtls_timeout -= (int) (LowResTimer() - start);
|
||||
start = LowResTimer();
|
||||
if (dtls_timeout < 0 || dtls_timeout > DTLS_TIMEOUT_MAX)
|
||||
return WOLFSSL_CBIO_ERR_TIMEOUT;
|
||||
@ -608,7 +608,7 @@ int EmbedReceiveFrom(WOLFSSL *ssl, char *buf, int sz, void *ctx)
|
||||
}
|
||||
#endif /* !NO_ASN_TIME */
|
||||
|
||||
recvd = (int)DTLS_RECVFROM_FUNCTION(sd, buf, sz, ssl->rflags,
|
||||
recvd = (int)DTLS_RECVFROM_FUNCTION(sd, buf, (size_t)sz, ssl->rflags,
|
||||
(SOCKADDR*)peer, peer != NULL ? &peerSz : NULL);
|
||||
|
||||
/* From the RECV(2) man page
|
||||
@ -716,7 +716,7 @@ int EmbedSendTo(WOLFSSL* ssl, char *buf, int sz, void *ctx)
|
||||
#endif
|
||||
}
|
||||
|
||||
sent = (int)DTLS_SENDTO_FUNCTION(sd, buf, sz, ssl->wflags,
|
||||
sent = (int)DTLS_SENDTO_FUNCTION(sd, buf, (size_t)sz, ssl->wflags,
|
||||
(const SOCKADDR*)peer, peerSz);
|
||||
|
||||
sent = TranslateReturnCode(sent, sd);
|
||||
@ -743,7 +743,7 @@ int EmbedReceiveFromMcast(WOLFSSL *ssl, char *buf, int sz, void *ctx)
|
||||
|
||||
WOLFSSL_ENTER("EmbedReceiveFromMcast");
|
||||
|
||||
recvd = (int)DTLS_RECVFROM_FUNCTION(sd, buf, sz, ssl->rflags, NULL, NULL);
|
||||
recvd = (int)DTLS_RECVFROM_FUNCTION(sd, buf, (size_t)sz, ssl->rflags, NULL, NULL);
|
||||
|
||||
recvd = TranslateReturnCode(recvd, sd);
|
||||
|
||||
@ -787,7 +787,7 @@ int EmbedGenerateCookie(WOLFSSL* ssl, byte *buf, int sz, void *ctx)
|
||||
|
||||
if (sz > WC_SHA256_DIGEST_SIZE)
|
||||
sz = WC_SHA256_DIGEST_SIZE;
|
||||
XMEMCPY(buf, digest, sz);
|
||||
XMEMCPY(buf, digest, (size_t)sz);
|
||||
|
||||
return sz;
|
||||
}
|
||||
@ -981,7 +981,7 @@ int wolfIO_Recv(SOCKET_T sd, char *buf, int sz, int rdFlags)
|
||||
{
|
||||
int recvd;
|
||||
|
||||
recvd = (int)RECV_FUNCTION(sd, buf, sz, rdFlags);
|
||||
recvd = (int)RECV_FUNCTION(sd, buf, (size_t)sz, rdFlags);
|
||||
recvd = TranslateReturnCode(recvd, (int)sd);
|
||||
|
||||
return recvd;
|
||||
@ -991,7 +991,7 @@ int wolfIO_Send(SOCKET_T sd, char *buf, int sz, int wrFlags)
|
||||
{
|
||||
int sent;
|
||||
|
||||
sent = (int)SEND_FUNCTION(sd, buf, sz, wrFlags);
|
||||
sent = (int)SEND_FUNCTION(sd, buf, (size_t)sz, wrFlags);
|
||||
sent = TranslateReturnCode(sent, (int)sd);
|
||||
|
||||
return sent;
|
||||
@ -1083,9 +1083,9 @@ int wolfIO_Send(SOCKET_T sd, char *buf, int sz, int wrFlags)
|
||||
}
|
||||
#endif /* HAVE_IO_TIMEOUT */
|
||||
|
||||
static int wolfIO_Word16ToString(char* d, word16 number)
|
||||
static word32 wolfIO_Word16ToString(char* d, word16 number)
|
||||
{
|
||||
int i = 0;
|
||||
word32 i = 0;
|
||||
word16 order = 10000;
|
||||
word16 digit;
|
||||
|
||||
@ -1100,7 +1100,7 @@ static int wolfIO_Word16ToString(char* d, word16 number)
|
||||
if (i > 0 || digit != 0)
|
||||
d[i++] = (char)digit + '0';
|
||||
if (digit != 0)
|
||||
number %= digit * order;
|
||||
number = (word16) (number % (digit * order));
|
||||
|
||||
order = (order > 1) ? order / 10 : 0;
|
||||
}
|
||||
@ -1115,7 +1115,7 @@ int wolfIO_TcpConnect(SOCKET_T* sockfd, const char* ip, word16 port, int to_sec)
|
||||
#ifdef HAVE_SOCKADDR
|
||||
int ret = 0;
|
||||
SOCKADDR_S addr;
|
||||
int sockaddr_len;
|
||||
socklen_t sockaddr_len;
|
||||
#if defined(HAVE_GETADDRINFO)
|
||||
/* use getaddrinfo */
|
||||
ADDRINFO hints;
|
||||
@ -1179,7 +1179,7 @@ int wolfIO_TcpConnect(SOCKET_T* sockfd, const char* ip, word16 port, int to_sec)
|
||||
}
|
||||
|
||||
sockaddr_len = answer->ai_addrlen;
|
||||
XMEMCPY(&addr, answer->ai_addr, sockaddr_len);
|
||||
XMEMCPY(&addr, answer->ai_addr, (size_t)sockaddr_len);
|
||||
freeaddrinfo(answer);
|
||||
#elif defined(WOLFSSL_USE_POPEN_HOST) && !defined(WOLFSSL_IPV6)
|
||||
{
|
||||
@ -1342,7 +1342,7 @@ int wolfIO_TcpBind(SOCKET_T* sockfd, word16 port)
|
||||
#ifdef HAVE_SOCKADDR
|
||||
int ret = 0;
|
||||
SOCKADDR_S addr;
|
||||
int sockaddr_len = sizeof(SOCKADDR_IN);
|
||||
socklen_t sockaddr_len = sizeof(SOCKADDR_IN);
|
||||
SOCKADDR_IN *sin = (SOCKADDR_IN *)&addr;
|
||||
|
||||
if (sockfd == NULL || port < 1) {
|
||||
@ -1473,7 +1473,7 @@ int wolfIO_DecodeUrl(const char* url, int urlSz, char* outName, char* outPath,
|
||||
|
||||
for (j = 0; j < i; j++) {
|
||||
if (port[j] < '0' || port[j] > '9') return -1;
|
||||
bigPort = (bigPort * 10) + (port[j] - '0');
|
||||
bigPort = (bigPort * 10) + (word32)(port[j] - '0');
|
||||
}
|
||||
if (outPort)
|
||||
*outPort = (word16)bigPort;
|
||||
@ -1528,7 +1528,7 @@ static int wolfIO_HttpProcessResponseBuf(int sfd, byte **recvBuf,
|
||||
return MEMORY_E;
|
||||
}
|
||||
|
||||
newRecvBuf = (byte*)XMALLOC(newRecvSz, heap, dynType);
|
||||
newRecvBuf = (byte*)XMALLOC((size_t)newRecvSz, heap, dynType);
|
||||
if (newRecvBuf == NULL) {
|
||||
WOLFSSL_MSG("wolfIO_HttpProcessResponseBuf malloc failed");
|
||||
return MEMORY_E;
|
||||
@ -1536,7 +1536,7 @@ static int wolfIO_HttpProcessResponseBuf(int sfd, byte **recvBuf,
|
||||
|
||||
/* if buffer already exists, then we are growing it */
|
||||
if (*recvBuf) {
|
||||
XMEMCPY(&newRecvBuf[pos], *recvBuf, *recvBufSz);
|
||||
XMEMCPY(&newRecvBuf[pos], *recvBuf, (size_t) *recvBufSz);
|
||||
XFREE(*recvBuf, heap, dynType);
|
||||
pos += *recvBufSz;
|
||||
*recvBuf = NULL;
|
||||
@ -1545,7 +1545,7 @@ static int wolfIO_HttpProcessResponseBuf(int sfd, byte **recvBuf,
|
||||
/* copy the remainder of the httpBuf into the respBuf */
|
||||
if (len != 0) {
|
||||
if (pos + len <= newRecvSz) {
|
||||
XMEMCPY(&newRecvBuf[pos], start, len);
|
||||
XMEMCPY(&newRecvBuf[pos], start, (size_t)len);
|
||||
pos += len;
|
||||
}
|
||||
else {
|
||||
@ -1629,7 +1629,7 @@ int wolfIO_HttpProcessResponse(int sfd, const char** appStrList,
|
||||
/* handle incomplete rx */
|
||||
if (end == NULL) {
|
||||
if (len != 0)
|
||||
XMEMMOVE(httpBuf, start, len);
|
||||
XMEMMOVE(httpBuf, start, (size_t)len);
|
||||
start = end = NULL;
|
||||
}
|
||||
/* when start is "\r\n" */
|
||||
@ -1755,7 +1755,7 @@ int wolfIO_HttpBuildRequest(const char *reqType, const char *domainName,
|
||||
return wolfIO_HttpBuildRequest_ex(reqType, domainName, path, pathLen, reqSz, contentType, "", buf, bufSize);
|
||||
}
|
||||
|
||||
int wolfIO_HttpBuildRequest_ex(const char *reqType, const char *domainName,
|
||||
int wolfIO_HttpBuildRequest_ex(const char *reqType, const char *domainName,
|
||||
const char *path, int pathLen, int reqSz, const char *contentType,
|
||||
const char *exHdrs, byte *buf, int bufSize)
|
||||
{
|
||||
@ -1797,7 +1797,7 @@ int wolfIO_HttpBuildRequest(const char *reqType, const char *domainName,
|
||||
maxLen =
|
||||
reqTypeLen +
|
||||
blankStrLen +
|
||||
pathLen +
|
||||
(word32)pathLen +
|
||||
http11StrLen +
|
||||
hostStrLen +
|
||||
domainNameLen +
|
||||
@ -1808,46 +1808,46 @@ int wolfIO_HttpBuildRequest(const char *reqType, const char *domainName,
|
||||
singleCrLfStrLen +
|
||||
exHdrsLen +
|
||||
doubleCrLfStrLen +
|
||||
1 /* null term */;
|
||||
(word32)1 /* null term */;
|
||||
if (maxLen > (word32)bufSize)
|
||||
return 0;
|
||||
|
||||
XSTRNCPY((char*)buf, reqType, bufSize);
|
||||
buf += reqTypeLen; bufSize -= reqTypeLen;
|
||||
XSTRNCPY((char*)buf, blankStr, bufSize);
|
||||
buf += blankStrLen; bufSize -= blankStrLen;
|
||||
XSTRNCPY((char*)buf, path, bufSize);
|
||||
buf += pathLen; bufSize -= pathLen;
|
||||
XSTRNCPY((char*)buf, http11Str, bufSize);
|
||||
buf += http11StrLen; bufSize -= http11StrLen;
|
||||
XSTRNCPY((char*)buf, reqType, (size_t)bufSize);
|
||||
buf += reqTypeLen; bufSize -= (int)reqTypeLen;
|
||||
XSTRNCPY((char*)buf, blankStr, (size_t)bufSize);
|
||||
buf += blankStrLen; bufSize -= (int)blankStrLen;
|
||||
XSTRNCPY((char*)buf, path, (size_t)bufSize);
|
||||
buf += pathLen; bufSize -= (int)pathLen;
|
||||
XSTRNCPY((char*)buf, http11Str, (size_t)bufSize);
|
||||
buf += http11StrLen; bufSize -= (int)http11StrLen;
|
||||
if (domainNameLen > 0) {
|
||||
XSTRNCPY((char*)buf, hostStr, bufSize);
|
||||
buf += hostStrLen; bufSize -= hostStrLen;
|
||||
XSTRNCPY((char*)buf, domainName, bufSize);
|
||||
buf += domainNameLen; bufSize -= domainNameLen;
|
||||
XSTRNCPY((char*)buf, hostStr, (size_t)bufSize);
|
||||
buf += hostStrLen; bufSize -= (int)hostStrLen;
|
||||
XSTRNCPY((char*)buf, domainName, (size_t)bufSize);
|
||||
buf += domainNameLen; bufSize -= (int)domainNameLen;
|
||||
}
|
||||
if (reqSz > 0 && reqSzStrLen > 0) {
|
||||
XSTRNCPY((char*)buf, contentLenStr, bufSize);
|
||||
buf += contentLenStrLen; bufSize -= contentLenStrLen;
|
||||
XSTRNCPY((char*)buf, reqSzStr, bufSize);
|
||||
buf += reqSzStrLen; bufSize -= reqSzStrLen;
|
||||
XSTRNCPY((char*)buf, contentLenStr, (size_t)bufSize);
|
||||
buf += contentLenStrLen; bufSize -= (int)contentLenStrLen;
|
||||
XSTRNCPY((char*)buf, reqSzStr, (size_t)bufSize);
|
||||
buf += reqSzStrLen; bufSize -= (int)reqSzStrLen;
|
||||
}
|
||||
if (contentTypeLen > 0) {
|
||||
XSTRNCPY((char*)buf, contentTypeStr, bufSize);
|
||||
buf += contentTypeStrLen; bufSize -= contentTypeStrLen;
|
||||
XSTRNCPY((char*)buf, contentType, bufSize);
|
||||
buf += contentTypeLen; bufSize -= contentTypeLen;
|
||||
XSTRNCPY((char*)buf, contentTypeStr, (size_t)bufSize);
|
||||
buf += contentTypeStrLen; bufSize -= (int)contentTypeStrLen;
|
||||
XSTRNCPY((char*)buf, contentType, (size_t)bufSize);
|
||||
buf += contentTypeLen; bufSize -= (int)contentTypeLen;
|
||||
}
|
||||
if (exHdrsLen > 0)
|
||||
{
|
||||
XSTRNCPY((char *)buf, singleCrLfStr, bufSize);
|
||||
XSTRNCPY((char *)buf, singleCrLfStr, (size_t)bufSize);
|
||||
buf += singleCrLfStrLen;
|
||||
bufSize -= singleCrLfStrLen;
|
||||
XSTRNCPY((char *)buf, exHdrs, bufSize);
|
||||
bufSize -= (int)singleCrLfStrLen;
|
||||
XSTRNCPY((char *)buf, exHdrs, (size_t)bufSize);
|
||||
buf += exHdrsLen;
|
||||
bufSize -= exHdrsLen;
|
||||
bufSize -= (int)exHdrsLen;
|
||||
}
|
||||
XSTRNCPY((char*)buf, doubleCrLfStr, bufSize);
|
||||
XSTRNCPY((char*)buf, doubleCrLfStr, (size_t)bufSize);
|
||||
buf += doubleCrLfStrLen;
|
||||
|
||||
#ifdef WOLFIO_DEBUG
|
||||
@ -1924,7 +1924,7 @@ int EmbedOcspLookup(void* ctx, const char* url, int urlSz,
|
||||
/* Note, the library uses the EmbedOcspRespFree() callback to
|
||||
* free this buffer. */
|
||||
int httpBufSz = HTTP_SCRATCH_BUFFER_SIZE;
|
||||
byte* httpBuf = (byte*)XMALLOC(httpBufSz, ctx, DYNAMIC_TYPE_OCSP);
|
||||
byte* httpBuf = (byte*)XMALLOC((size_t)httpBufSz, ctx, DYNAMIC_TYPE_OCSP);
|
||||
|
||||
if (httpBuf == NULL) {
|
||||
WOLFSSL_MSG("Unable to create OCSP response buffer");
|
||||
@ -2031,7 +2031,7 @@ int EmbedCrlLookup(WOLFSSL_CRL* crl, const char* url, int urlSz)
|
||||
}
|
||||
else {
|
||||
int httpBufSz = HTTP_SCRATCH_BUFFER_SIZE;
|
||||
byte* httpBuf = (byte*)XMALLOC(httpBufSz, crl->heap,
|
||||
byte* httpBuf = (byte*)XMALLOC((size_t)httpBufSz, crl->heap,
|
||||
DYNAMIC_TYPE_CRL);
|
||||
if (httpBuf == NULL) {
|
||||
WOLFSSL_MSG("Unable to create CRL response buffer");
|
||||
|
Loading…
x
Reference in New Issue
Block a user