Skip to content

Commit b237730

Browse files
committed
fix type conversion in ssl* files
1 parent 4d837e7 commit b237730

3 files changed

Lines changed: 21 additions & 21 deletions

File tree

src/ssl.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,7 +1684,7 @@ const char* wolfSSL_get_shared_ciphers(WOLFSSL* ssl, char* buf, int len)
16841684
return NULL;
16851685

16861686
cipher = wolfSSL_get_cipher_name_iana(ssl);
1687-
len = (int)min((word32)len, (int)(XSTRLEN(cipher) + 1));
1687+
len = (int)min((word32)len, (word32)(XSTRLEN(cipher) + 1));
16881688
XMEMCPY(buf, cipher, len);
16891689
return buf;
16901690
}
@@ -4673,7 +4673,7 @@ int wolfSSL_pending(WOLFSSL* ssl)
46734673
if (ssl == NULL)
46744674
return WOLFSSL_FAILURE;
46754675

4676-
return ssl->buffers.clearOutputBuffer.length;
4676+
return (int)ssl->buffers.clearOutputBuffer.length;
46774677
}
46784678

46794679
int wolfSSL_has_pending(const WOLFSSL* ssl)
@@ -10391,7 +10391,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
1039110391
sending += (int)iov[i].iov_len;
1039210392

1039310393
if (sending > (int)sizeof(staticBuffer)) {
10394-
myBuffer = (byte*)XMALLOC(sending, ssl->heap,
10394+
myBuffer = (byte*)XMALLOC((size_t)sending, ssl->heap,
1039510395
DYNAMIC_TYPE_WRITEV);
1039610396
if (!myBuffer)
1039710397
return MEMORY_ERROR;
@@ -11734,7 +11734,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
1173411734
WOLFSSL_MSG("wolfSSL options are set through API calls and macros");
1173511735
if(ctx == NULL)
1173611736
return BAD_FUNC_ARG;
11737-
return ctx->mask;
11737+
return (long)ctx->mask;
1173811738
}
1173911739

1174011740
/* forward declaration */
@@ -11747,7 +11747,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
1174711747
if (ctx == NULL)
1174811748
return BAD_FUNC_ARG;
1174911749

11750-
ctx->mask = wolf_set_options(ctx->mask, opt);
11750+
ctx->mask = (unsigned long)wolf_set_options((long)ctx->mask, opt);
1175111751
#if defined(HAVE_SESSION_TICKET) && (defined(OPENSSL_EXTRA) \
1175211752
|| defined(HAVE_WEBSERVER) || defined(WOLFSSL_WPAS_SMALL))
1175311753
if ((ctx->mask & WOLFSSL_OP_NO_TICKET) == WOLFSSL_OP_NO_TICKET) {
@@ -11763,16 +11763,16 @@ int wolfSSL_set_compression(WOLFSSL* ssl)
1176311763
#endif
1176411764
*/
1176511765
#endif
11766-
return ctx->mask;
11766+
return (long)ctx->mask;
1176711767
}
1176811768

1176911769
long wolfSSL_CTX_clear_options(WOLFSSL_CTX* ctx, long opt)
1177011770
{
1177111771
WOLFSSL_ENTER("wolfSSL_CTX_clear_options");
1177211772
if(ctx == NULL)
1177311773
return BAD_FUNC_ARG;
11774-
ctx->mask &= ~opt;
11775-
return ctx->mask;
11774+
ctx->mask &= (unsigned long)~opt;
11775+
return (long)ctx->mask;
1177611776
}
1177711777

1177811778
#ifdef OPENSSL_EXTRA
@@ -14277,7 +14277,7 @@ word32 wolfSSL_CIPHER_get_id(const WOLFSSL_CIPHER* cipher)
1427714277
WOLFSSL_ENTER("wolfSSL_CIPHER_get_id");
1427814278

1427914279
if (cipher && cipher->ssl) {
14280-
cipher_id = (cipher->ssl->options.cipherSuite0 << 8) |
14280+
cipher_id = (word16)(cipher->ssl->options.cipherSuite0 << 8) |
1428114281
cipher->ssl->options.cipherSuite;
1428214282
}
1428314283

@@ -15970,7 +15970,7 @@ long wolfSSL_set_options(WOLFSSL* ssl, long op)
1597015970
return 0;
1597115971
}
1597215972

15973-
ssl->options.mask = wolf_set_options(ssl->options.mask, op);
15973+
ssl->options.mask = (unsigned long)wolf_set_options((long)ssl->options.mask, op);
1597415974

1597515975
if ((ssl->options.mask & WOLFSSL_OP_NO_TLSv1_3) == WOLFSSL_OP_NO_TLSv1_3) {
1597615976
WOLFSSL_MSG("Disabling TLS 1.3");
@@ -16073,7 +16073,7 @@ long wolfSSL_set_options(WOLFSSL* ssl, long op)
1607316073
}
1607416074
}
1607516075

16076-
return ssl->options.mask;
16076+
return (long)ssl->options.mask;
1607716077
}
1607816078

1607916079

@@ -16082,7 +16082,7 @@ long wolfSSL_get_options(const WOLFSSL* ssl)
1608216082
WOLFSSL_ENTER("wolfSSL_get_options");
1608316083
if(ssl == NULL)
1608416084
return WOLFSSL_FAILURE;
16085-
return ssl->options.mask;
16085+
return (long)ssl->options.mask;
1608616086
}
1608716087

1608816088
#if defined(HAVE_SECURE_RENEGOTIATION) \

src/ssl_load.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,7 +1561,7 @@ static void ProcessBufferCertSetHave(WOLFSSL_CTX* ctx, WOLFSSL* ssl,
15611561
#endif
15621562
#ifndef WC_STRICT_SIG
15631563
if ((ctx != NULL) || (ssl != NULL)) {
1564-
wolfssl_set_have_from_key_oid(ctx, ssl, cert->keyOID);
1564+
wolfssl_set_have_from_key_oid(ctx, ssl, (int)cert->keyOID);
15651565
}
15661566
#else
15671567
/* Set whether ECC is available based on signature available. */
@@ -5272,8 +5272,8 @@ int wolfSSL_SetTmpDH(WOLFSSL* ssl, const unsigned char* p, int pSz,
52725272

52735273
if (ret == 1) {
52745274
/* Allocate buffers for p and g to be assigned into SSL. */
5275-
pAlloc = (byte*)XMALLOC(pSz, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY);
5276-
gAlloc = (byte*)XMALLOC(gSz, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY);
5275+
pAlloc = (byte*)XMALLOC((size_t)pSz, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY);
5276+
gAlloc = (byte*)XMALLOC((size_t)gSz, ssl->heap, DYNAMIC_TYPE_PUBLIC_KEY);
52775277
if ((pAlloc == NULL) || (gAlloc == NULL)) {
52785278
/* Memory will be freed below in the (ret != 1) block */
52795279
ret = MEMORY_E;
@@ -5332,7 +5332,7 @@ static int wolfssl_check_dh_key(unsigned char* p, int pSz, unsigned char* g,
53325332
/* Initialize a DH object. */
53335333
if ((ret = wc_InitDhKey(checkKey)) == 0) {
53345334
/* Check DH parameters. */
5335-
ret = wc_DhSetCheckKey(checkKey, p, (word32)pSz, g, gSz, NULL, 0, 0, &rng);
5335+
ret = wc_DhSetCheckKey(checkKey, p, (word32)pSz, g, (word32)gSz, NULL, 0, 0, &rng);
53365336
/* Dispose of DH object. */
53375337
wc_FreeDhKey(checkKey);
53385338
}
@@ -5431,8 +5431,8 @@ int wolfSSL_CTX_SetTmpDH(WOLFSSL_CTX* ctx, const unsigned char* p, int pSz,
54315431

54325432
if (ret == 1) {
54335433
/* Allocate buffers for p and g to be assigned into SSL context. */
5434-
pAlloc = (byte*)XMALLOC(pSz, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY);
5435-
gAlloc = (byte*)XMALLOC(gSz, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY);
5434+
pAlloc = (byte*)XMALLOC((size_t)pSz, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY);
5435+
gAlloc = (byte*)XMALLOC((size_t)gSz, ctx->heap, DYNAMIC_TYPE_PUBLIC_KEY);
54365436
if ((pAlloc == NULL) || (gAlloc == NULL)) {
54375437
ret = MEMORY_E;
54385438
}
@@ -5687,11 +5687,11 @@ static int ws_ctx_ssl_set_tmp_dh(WOLFSSL_CTX* ctx, WOLFSSL* ssl,
56875687
}
56885688
else if (ssl != NULL) {
56895689
/* Set p and g into SSL. */
5690-
res = wolfssl_set_tmp_dh(ssl, p, (int)pSz, g, gSz);
5690+
res = wolfssl_set_tmp_dh(ssl, p, (int)pSz, g, (int)gSz);
56915691
}
56925692
else {
56935693
/* Set p and g into SSL context. */
5694-
res = wolfssl_ctx_set_tmp_dh(ctx, p, (int)pSz, g, gSz);
5694+
res = wolfssl_ctx_set_tmp_dh(ctx, p, (int)pSz, g, (int)gSz);
56955695
}
56965696
}
56975697

src/ssl_sess.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ WOLFSSL_SESSION* wolfSSL_GetSessionClient(WOLFSSL* ssl, const byte* id, int len)
10041004
#else
10051005
current = &sessRow->Sessions[clSess[idx].serverIdx];
10061006
#endif
1007-
if (current && XMEMCMP(current->serverID, id, len) == 0) {
1007+
if (current && XMEMCMP(current->serverID, id, (unsigned long)len) == 0) {
10081008
WOLFSSL_MSG("Found a serverid match for client");
10091009
if (LowResTimer() < (current->bornOn + current->timeout)) {
10101010
WOLFSSL_MSG("Session valid");

0 commit comments

Comments
 (0)