@@ -376,6 +376,11 @@ static PrivKeyList* PrivKeyList_new(void)
376376/* */
377377static void PrivKeyList_free (PrivKeyList * pList )
378378{
379+ if (NULL == pList ) {
380+ log_error ("%s::%s(%d) : pList is NULL" , LOG_INF );
381+ return ;
382+ }
383+
379384 if (0 < pList -> key_count )
380385 {
381386 for (int i = 0 ; pList -> key_count > i ; i ++ )
@@ -460,6 +465,11 @@ static PEMx509List* PEMx509List_new(void)
460465/* */
461466static void PEMx509List_free (PEMx509List * pList )
462467{
468+ if (NULL == pList ) {
469+ log_error ("%s::%s(%d) : pList is NULL" , LOG_INF );
470+ return ;
471+ }
472+
463473 if (0 < pList -> item_count )
464474 {
465475 for (int i = 0 ; pList -> item_count > i ; i ++ )
@@ -665,8 +675,11 @@ static bool PemInventoryItem_populate(PemInventoryItem* pem, X509* cert)
665675 if (pem && cert )
666676 {
667677 thumb = compute_thumbprint (cert );
668- log_verbose ("%s::%s(%d) : Thumbprint: %s" , LOG_INF ,
669- NULL == thumb ? "" : thumb );
678+ if (NULL == thumb ) {
679+ log_error ("%s::%s(%d) : Failed to compute thumbprint" , LOG_INF );
680+ return false;
681+ }
682+ log_verbose ("%s::%s(%d) : Thumbprint: %s" , LOG_INF , thumb );
670683 contLen = i2d_X509 (cert , & certContent );
671684 log_trace ("%s::%s(%d) : contLen = %d" , LOG_INF , contLen );
672685
@@ -729,7 +742,11 @@ static bool is_cert_key_match(X509* cert, EVP_PKEY* key)
729742
730743 if (cert && key )
731744 {
732- certPubKey = X509_get_pubkey (cert );
745+ certPubKey = X509_get_pubkey (cert );
746+ if (NULL == certPubKey ) {
747+ log_error ("%s::%s(%d) : Failed to get public key from certificate" , LOG_INF );
748+ return false;
749+ }
733750 certBaseId = EVP_PKEY_base_id (certPubKey ); /* Get the key type */
734751 keyBaseId = EVP_PKEY_base_id (key ); /* Get the priv key type */
735752
@@ -792,11 +809,22 @@ static bool is_cert_key_match(X509* cert, EVP_PKEY* key)
792809 /* */
793810 privPubBytes = EC_POINT_point2hex (privGroup , privPoint ,
794811 POINT_CONVERSION_UNCOMPRESSED , NULL );
812+ if (NULL == privPubBytes ) {
813+ log_error ("%s::%s(%d) : Failed to convert private key EC_POINT to hex" , LOG_INF );
814+ ret = false;
815+ break ;
816+ }
795817 /* get EC_POINT public key */
796818 certPoint = EC_KEY_get0_public_key (ecCert );
797819 certGroup = EC_KEY_get0_group (ecCert ); /* get EC_GROUP */
798820 certPubBytes = EC_POINT_point2hex (certGroup , certPoint ,
799821 POINT_CONVERSION_UNCOMPRESSED , NULL );
822+ if (NULL == certPubBytes ) {
823+ log_error ("%s::%s(%d) : Failed to convert certificate EC_POINT to hex" , LOG_INF );
824+ OPENSSL_free (privPubBytes );
825+ ret = false;
826+ break ;
827+ }
800828
801829 /* Now that we have the point on the curve compare them, */
802830 /* they should be equal if the keys match */
0 commit comments