Skip to content

Commit

Permalink
Merge pull request wolfSSL#7918 from SparkiDev/type_conversion_fixes_3
Browse files Browse the repository at this point in the history
Type conversion fixes
  • Loading branch information
douzzer authored Sep 4, 2024
2 parents 121b8c5 + ed7beb4 commit b26fa6c
Show file tree
Hide file tree
Showing 8 changed files with 547 additions and 505 deletions.
2 changes: 1 addition & 1 deletion examples/client/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -3225,7 +3225,7 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
#if (defined(WOLFSSL_SCTP) || defined(WOLFSSL_DTLS_MTU)) && \
defined(WOLFSSL_DTLS)
if (dtlsMTU)
wolfSSL_CTX_dtls_set_mtu(ctx, dtlsMTU);
wolfSSL_CTX_dtls_set_mtu(ctx, (unsigned short)dtlsMTU);
#endif

#ifndef NO_DH
Expand Down
2 changes: 1 addition & 1 deletion examples/server/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -2684,7 +2684,7 @@ THREAD_RETURN WOLFSSL_THREAD server_test(void* args)
#if (defined(WOLFSSL_SCTP) || defined(WOLFSSL_DTLS_MTU)) && \
defined(WOLFSSL_DTLS)
if (dtlsMTU)
wolfSSL_CTX_dtls_set_mtu(ctx, dtlsMTU);
wolfSSL_CTX_dtls_set_mtu(ctx, (unsigned short)dtlsMTU);
#endif

#ifdef WOLFSSL_SCTP
Expand Down
2 changes: 1 addition & 1 deletion src/ocsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1432,7 +1432,7 @@ WOLFSSL_OCSP_REQ_CTX* wolfSSL_OCSP_REQ_CTX_new(WOLFSSL_BIO *bio, int maxline)
DYNAMIC_TYPE_OPENSSL);
if (ret != NULL) {
XMEMSET(ret, 0, sizeof(*ret));
ret->buf = (byte*)XMALLOC(maxline, NULL, DYNAMIC_TYPE_OPENSSL);
ret->buf = (byte*)XMALLOC((word32)maxline, NULL, DYNAMIC_TYPE_OPENSSL);
if (ret->buf == NULL)
goto error;
ret->reqResp = wolfSSL_BIO_new(wolfSSL_BIO_s_mem());
Expand Down
36 changes: 18 additions & 18 deletions wolfcrypt/src/asn.c
Original file line number Diff line number Diff line change
Expand Up @@ -5652,7 +5652,7 @@ int EncodeObjectId(const word16* in, word32 inSz, byte* out, word32* outSz)
}

/* compute length of encoded OID */
d = (in[0] * 40) + in[1];
d = ((word32)in[0] * 40) + in[1];
len = 0;
for (i = 1; i < (int)inSz; i++) {
x = 0;
Expand All @@ -5675,7 +5675,7 @@ int EncodeObjectId(const word16* in, word32 inSz, byte* out, word32* outSz)
}

/* calc first byte */
d = (in[0] * 40) + in[1];
d = ((word32)in[0] * 40) + in[1];

/* encode bytes */
x = 0;
Expand Down Expand Up @@ -5710,7 +5710,7 @@ int EncodeObjectId(const word16* in, word32 inSz, byte* out, word32* outSz)
}

/* return length */
*outSz = len;
*outSz = (word32)len;

return 0;
}
Expand Down Expand Up @@ -13476,12 +13476,12 @@ static int GenerateDNSEntryRIDString(DNS_entry* entry, void* heap)
}

if (i < tmpSize - 1) {
ret = XSNPRINTF(oidName + j, MAX_OID_SZ - j, "%d.",
tmpName[i]);
ret = XSNPRINTF(oidName + j, (word32)(MAX_OID_SZ - j),
"%d.", tmpName[i]);
}
else {
ret = XSNPRINTF(oidName + j, MAX_OID_SZ - j, "%d",
tmpName[i]);
ret = XSNPRINTF(oidName + j, (word32)(MAX_OID_SZ - j),
"%d", tmpName[i]);
}

if (ret >= 0) {
Expand All @@ -13500,15 +13500,15 @@ static int GenerateDNSEntryRIDString(DNS_entry* entry, void* heap)
if (ret == 0) {
nameSz = (int)XSTRLEN((const char*)finalName);

entry->ridString = (char*)XMALLOC(nameSz + 1, heap,
entry->ridString = (char*)XMALLOC((word32)(nameSz + 1), heap,
DYNAMIC_TYPE_ALTNAME);

if (entry->ridString == NULL) {
ret = MEMORY_E;
}

if (ret == 0) {
XMEMCPY(entry->ridString, finalName, nameSz + 1);
XMEMCPY(entry->ridString, finalName, (word32)(nameSz + 1));
}
}

Expand Down Expand Up @@ -28121,9 +28121,9 @@ static int EncodeName(EncodedName* name, const char* nameStr,
break;
#ifdef WOLFSSL_CUSTOM_OID
case ASN_CUSTOM_NAME:
nameSz = cname->custom.valSz;
nameSz = (word32)cname->custom.valSz;
oid = cname->custom.oid;
oidSz = cname->custom.oidSz;
oidSz = (word32)cname->custom.oidSz;
break;
#endif
#ifdef WOLFSSL_CERT_REQ
Expand Down Expand Up @@ -28447,8 +28447,8 @@ static int SetNameRdnItems(ASNSetData* dataASN, ASNItem* namesASN,
else if (type == ASN_CUSTOM_NAME) {
#ifdef WOLFSSL_CUSTOM_OID
SetRdnItems(namesASN + idx, dataASN + idx, name->custom.oid,
name->custom.oidSz, name->custom.enc,
name->custom.val, name->custom.valSz);
(word32)name->custom.oidSz, (byte)name->custom.enc,
name->custom.val, (word32)name->custom.valSz);
#endif
}
else {
Expand Down Expand Up @@ -32486,7 +32486,7 @@ int wc_SetExtKeyUsageOID(Cert *cert, const char *in, word32 sz, byte idx,
}

XMEMCPY(cert->extKeyUsageOID[idx], oid, oidSz);
cert->extKeyUsageOIDSz[idx] = oidSz;
cert->extKeyUsageOIDSz[idx] = (byte)oidSz;
cert->extKeyUsage |= EXTKEYUSE_USER;

return 0;
Expand Down Expand Up @@ -32522,7 +32522,7 @@ int wc_SetCustomExtension(Cert *cert, int critical, const char *oid,
ext->oid = (char*)oid;
ext->crit = (critical == 0) ? 0 : 1;
ext->val = (byte*)der;
ext->valSz = derSz;
ext->valSz = (int)derSz;

cert->customCertExtCount++;
return 0;
Expand Down Expand Up @@ -38724,15 +38724,15 @@ int ParseCRL(RevokedCert* rcert, DecodedCRL* dcrl, const byte* buff, word32 sz,
tbsParams =
GetASNItem_Addr(dataASN[CRLASN_IDX_TBS_SIGALGO_PARAMS],
buff);
tbsParamsSz =
tbsParamsSz =(int)
GetASNItem_Length(dataASN[CRLASN_IDX_TBS_SIGALGO_PARAMS],
buff);
}
if (dataASN[CRLASN_IDX_SIGALGO_PARAMS].tag != 0) {
sigParams =
GetASNItem_Addr(dataASN[CRLASN_IDX_SIGALGO_PARAMS],
buff);
sigParamsSz =
sigParamsSz = (int)
GetASNItem_Length(dataASN[CRLASN_IDX_SIGALGO_PARAMS],
buff);
dcrl->sigParamsIndex =
Expand All @@ -38759,7 +38759,7 @@ int ParseCRL(RevokedCert* rcert, DecodedCRL* dcrl, const byte* buff, word32 sz,
ret = ASN_PARSE_E;
}
else if ((tbsParamsSz > 0) &&
(XMEMCMP(tbsParams, sigParams, tbsParamsSz) != 0)) {
(XMEMCMP(tbsParams, sigParams, (word32)tbsParamsSz) != 0)) {
WOLFSSL_MSG("CRL TBS and signature parameter mismatch");
ret = ASN_PARSE_E;
}
Expand Down
Loading

0 comments on commit b26fa6c

Please sign in to comment.