@@ -291,15 +291,16 @@ static WC_INLINE int wolfssl_cm_get_certs_der(WOLFSSL_CERT_MANAGER* cm,
291291
292292 if (!err ) {
293293 /* Allocate memory for pointers to each DER buffer. */
294- certBuffers = (DerBuffer * * )XMALLOC (sizeof (DerBuffer * ) * numCerts ,
295- cm -> heap , DYNAMIC_TYPE_TMP_BUFFER );
294+ certBuffers = (DerBuffer * * )XMALLOC (
295+ sizeof (DerBuffer * ) * (size_t )numCerts , cm -> heap ,
296+ DYNAMIC_TYPE_TMP_BUFFER );
296297 if (certBuffers == NULL ) {
297298 err = 1 ;
298299 }
299300 }
300301 if (!err ) {
301302 /* Reset pointers. */
302- XMEMSET (certBuffers , 0 , sizeof (DerBuffer * ) * numCerts );
303+ XMEMSET (certBuffers , 0 , sizeof (DerBuffer * ) * ( size_t ) numCerts );
303304 }
304305
305306 /* Copy the certs locally so that we can release the caLock. If the lock
@@ -382,7 +383,7 @@ WOLFSSL_STACK* wolfSSL_CertManagerGetCerts(WOLFSSL_CERT_MANAGER* cm)
382383 /* Get pointer to DER encoding of certificate. */
383384 derBuffer = certBuffers [i ]-> buffer ;
384385 /* Decode certificate. */
385- wolfSSL_d2i_X509 (& x509 , & derBuffer , certBuffers [i ]-> length );
386+ wolfSSL_d2i_X509 (& x509 , & derBuffer , ( int ) certBuffers [i ]-> length );
386387 if (x509 == NULL ) {
387388 err = 1 ;
388389 }
@@ -816,13 +817,13 @@ int wolfSSL_CertManagerVerify(WOLFSSL_CERT_MANAGER* cm, const char* fname,
816817#endif
817818 {
818819 WOLFSSL_MSG ("Getting dynamic buffer" );
819- buff = (byte * )XMALLOC (sz , cm -> heap , DYNAMIC_TYPE_FILE );
820+ buff = (byte * )XMALLOC (( size_t ) sz , cm -> heap , DYNAMIC_TYPE_FILE );
820821 if (buff == NULL ) {
821822 ret = WOLFSSL_BAD_FILE ;
822823 }
823824 }
824825 /* Read all the file into buffer. */
825- if ((ret == WOLFSSL_SUCCESS ) && (( size_t ) XFREAD (buff , 1 , sz , file ) !=
826+ if ((ret == WOLFSSL_SUCCESS ) && (XFREAD (buff , 1 , ( size_t ) sz , file ) !=
826827 (size_t )sz )) {
827828 ret = WOLFSSL_BAD_FILE ;
828829 }
@@ -942,7 +943,7 @@ static WC_INLINE int cm_get_signer_memory(Signer* signer)
942943#endif
943944
944945 /* Add dynamic bytes needed. */
945- sz += signer -> pubKeySize ;
946+ sz += ( int ) signer -> pubKeySize ;
946947 sz += signer -> nameLen ;
947948
948949 return sz ;
@@ -1103,7 +1104,7 @@ static WC_INLINE int cm_restore_cert_row(WOLFSSL_CERT_MANAGER* cm,
11031104 /* Copy in public key. */
11041105 XMEMCPY (publicKey , current + idx , signer -> pubKeySize );
11051106 signer -> publicKey = publicKey ;
1106- idx += signer -> pubKeySize ;
1107+ idx += ( int ) signer -> pubKeySize ;
11071108
11081109 /* Copy in certificate name length. */
11091110 XMEMCPY (& signer -> nameLen , current + idx , sizeof (signer -> nameLen ));
@@ -1117,7 +1118,7 @@ static WC_INLINE int cm_restore_cert_row(WOLFSSL_CERT_MANAGER* cm,
11171118 }
11181119 if (ret == 0 ) {
11191120 /* Allocate memory for public key to be stored in. */
1120- signer -> name = (char * )XMALLOC (signer -> nameLen , cm -> heap ,
1121+ signer -> name = (char * )XMALLOC (( size_t ) signer -> nameLen , cm -> heap ,
11211122 DYNAMIC_TYPE_SUBJECT_CN );
11221123 if (signer -> name == NULL ) {
11231124 ret = MEMORY_E ;
@@ -1126,7 +1127,7 @@ static WC_INLINE int cm_restore_cert_row(WOLFSSL_CERT_MANAGER* cm,
11261127
11271128 if (ret == 0 ) {
11281129 /* Copy in certificate name. */
1129- XMEMCPY (signer -> name , current + idx , signer -> nameLen );
1130+ XMEMCPY (signer -> name , current + idx , ( size_t ) signer -> nameLen );
11301131 idx += signer -> nameLen ;
11311132
11321133 /* Copy in hash of subject name. */
@@ -1190,15 +1191,15 @@ static WC_INLINE int cm_store_cert_row(WOLFSSL_CERT_MANAGER* cm, byte* current,
11901191 added += (int )sizeof (list -> keyOID );
11911192
11921193 /* Public key. */
1193- XMEMCPY (current + added , list -> publicKey , list -> pubKeySize );
1194- added += list -> pubKeySize ;
1194+ XMEMCPY (current + added , list -> publicKey , ( size_t ) list -> pubKeySize );
1195+ added += ( int ) list -> pubKeySize ;
11951196
11961197 /* Certificate name length. */
11971198 XMEMCPY (current + added , & list -> nameLen , sizeof (list -> nameLen ));
11981199 added += (int )sizeof (list -> nameLen );
11991200
12001201 /* Certificate name. */
1201- XMEMCPY (current + added , list -> name , list -> nameLen );
1202+ XMEMCPY (current + added , list -> name , ( size_t ) list -> nameLen );
12021203 added += list -> nameLen ;
12031204
12041205 /* Hash of subject name. */
@@ -1287,8 +1288,6 @@ int CM_SaveCertCache(WOLFSSL_CERT_MANAGER* cm, const char* fname)
12871288{
12881289 XFILE file ;
12891290 int ret = WOLFSSL_SUCCESS ;
1290- int memSz ;
1291- byte * mem ;
12921291
12931292 WOLFSSL_ENTER ("CM_SaveCertCache" );
12941293
@@ -1306,17 +1305,18 @@ int CM_SaveCertCache(WOLFSSL_CERT_MANAGER* cm, const char* fname)
13061305 }
13071306
13081307 if (ret == WOLFSSL_SUCCESS ) {
1308+ byte * mem ;
13091309 /* Calculate size of memory required to store CA table. */
1310- memSz = cm_get_cert_cache_mem_size (cm );
1310+ size_t memSz = ( size_t ) cm_get_cert_cache_mem_size (cm );
13111311 /* Allocate memory to hold CA table. */
1312- mem = (byte * )XMALLOC (memSz , cm -> heap , DYNAMIC_TYPE_TMP_BUFFER );
1312+ mem = (byte * )XMALLOC (memSz , cm -> heap , DYNAMIC_TYPE_TMP_BUFFER );
13131313 if (mem == NULL ) {
13141314 WOLFSSL_MSG ("Alloc for tmp buffer failed" );
13151315 ret = MEMORY_E ;
13161316 }
13171317 if (ret == WOLFSSL_SUCCESS ) {
13181318 /* Store CA table in memory. */
1319- ret = cm_do_mem_save_cert_cache (cm , mem , memSz );
1319+ ret = cm_do_mem_save_cert_cache (cm , mem , ( int ) memSz );
13201320 }
13211321 if (ret == WOLFSSL_SUCCESS ) {
13221322 /* Write memory to file. */
@@ -1753,7 +1753,7 @@ int wolfSSL_CertManagerCheckCRL(WOLFSSL_CERT_MANAGER* cm,
17531753 #endif
17541754 {
17551755 /* Initialize decoded certificate with buffer. */
1756- InitDecodedCert (cert , der , sz , NULL );
1756+ InitDecodedCert (cert , der , ( word32 ) sz , NULL );
17571757
17581758 /* Parse certificate and perform CRL checks. */
17591759 ret = ParseCertRelative (cert , CERT_TYPE , VERIFY_CRL , cm );
@@ -2224,7 +2224,7 @@ int wolfSSL_CertManagerCheckOCSP(WOLFSSL_CERT_MANAGER* cm,
22242224 #endif
22252225 {
22262226 /* Initialize decoded certificate with buffer. */
2227- InitDecodedCert (cert , der , sz , NULL );
2227+ InitDecodedCert (cert , der , ( word32 ) sz , NULL );
22282228
22292229 /* Parse certificate and perform CRL checks. */
22302230 ret = ParseCertRelative (cert , CERT_TYPE , VERIFY_OCSP , cm );
@@ -2307,14 +2307,14 @@ int wolfSSL_CertManagerSetOCSPOverrideURL(WOLFSSL_CERT_MANAGER* cm,
23072307 /* Calculate size of URL string. Include terminator character. */
23082308 int urlSz = (int )XSTRLEN (url ) + 1 ;
23092309 /* Allocate memory for URL to be copied into. */
2310- cm -> ocspOverrideURL = (char * )XMALLOC (urlSz , cm -> heap ,
2310+ cm -> ocspOverrideURL = (char * )XMALLOC (( size_t ) urlSz , cm -> heap ,
23112311 DYNAMIC_TYPE_URL );
23122312 if (cm -> ocspOverrideURL == NULL ) {
23132313 ret = MEMORY_E ;
23142314 }
23152315 if (ret == WOLFSSL_SUCCESS ) {
23162316 /* Copy URL into certificate manager. */
2317- XMEMCPY (cm -> ocspOverrideURL , url , urlSz );
2317+ XMEMCPY (cm -> ocspOverrideURL , url , ( size_t ) urlSz );
23182318 }
23192319 }
23202320 else {
0 commit comments