[edk2-devel] [PATCH] CryptoPkg/BaseCryptLib: Use cmp-operator for non-Boolean comparisons

Gao, Zhichao posted 1 patch 4 years, 8 months ago
Failed in applying to current master (apply log)
.../BaseCryptLib/Pk/CryptPkcs7VerifyEku.c        | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
[edk2-devel] [PATCH] CryptoPkg/BaseCryptLib: Use cmp-operator for non-Boolean comparisons
Posted by Gao, Zhichao 4 years, 8 months ago
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2027

Refer to CSS_2_1 5.7.2.1 "Non-Boolean comparisons must use a
compare operator (==, !=, >, < >=, <=).", use compare operator
for the non-boolean comparisons.

Cc: Jian Wang <jian.j.wang@intel.com>
Cc: Ting Ye <ting.ye@intel.com>
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
---
 .../BaseCryptLib/Pk/CryptPkcs7VerifyEku.c        | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyEku.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyEku.c
index a0ea3f85eb..229c244b26 100644
--- a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyEku.c
+++ b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyEku.c
@@ -111,7 +111,7 @@ Exit:
   //
   // Release Resources
   //
-  if (Signers) {
+  if (Signers != NULL) {
     sk_X509_free (Signers);
   }
 
@@ -230,11 +230,11 @@ Exit:
   //
   // Release Resources
   //
-  if (ClonedCert) {
+  if (ClonedCert != NULL) {
     X509_free (ClonedCert);
   }
 
-  if (Eku) {
+  if (Eku != NULL) {
     sk_ASN1_OBJECT_pop_free (Eku, ASN1_OBJECT_free);
   }
 
@@ -281,13 +281,13 @@ CheckEKUs(
     //
     // Finding required EKU in cert.
     //
-    if (Asn1ToFind) {
+    if (Asn1ToFind != NULL) {
       ASN1_OBJECT_free(Asn1ToFind);
       Asn1ToFind = NULL;
     }
 
     Asn1ToFind = OBJ_txt2obj (RequiredEKUs[Index], 0);
-    if (!Asn1ToFind) {
+    if (Asn1ToFind == NULL) {
       //
       // Fail to convert required EKU to ASN1.
       //
@@ -313,7 +313,7 @@ CheckEKUs(
 
 Exit:
 
-  if (Asn1ToFind) {
+  if (Asn1ToFind != NULL) {
     ASN1_OBJECT_free(Asn1ToFind);
   }
 
@@ -508,11 +508,11 @@ Exit:
     free (SignedData);
   }
 
-  if (SignerCert) {
+  if (SignerCert != NULL) {
     X509_free (SignerCert);
   }
 
-  if (Pkcs7) {
+  if (Pkcs7 != NULL) {
     PKCS7_free (Pkcs7);
   }
 
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44577): https://edk2.groups.io/g/devel/message/44577
Mute This Topic: https://groups.io/mt/32649746/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH] CryptoPkg/BaseCryptLib: Use cmp-operator for non-Boolean comparisons
Posted by Wang, Jian J 4 years, 8 months ago

Reviewed-by: Jian J Wang <jian.j.wang@intel.com>

> -----Original Message-----
> From: Gao, Zhichao
> Sent: Tuesday, July 30, 2019 9:48 AM
> To: devel@edk2.groups.io
> Cc: Wang, Jian J <jian.j.wang@intel.com>; Ye, Ting <ting.ye@intel.com>
> Subject: [PATCH] CryptoPkg/BaseCryptLib: Use cmp-operator for non-
> Boolean comparisons
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2027
> 
> Refer to CSS_2_1 5.7.2.1 "Non-Boolean comparisons must use a
> compare operator (==, !=, >, < >=, <=).", use compare operator
> for the non-boolean comparisons.
> 
> Cc: Jian Wang <jian.j.wang@intel.com>
> Cc: Ting Ye <ting.ye@intel.com>
> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
> ---
>  .../BaseCryptLib/Pk/CryptPkcs7VerifyEku.c        | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyEku.c
> b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyEku.c
> index a0ea3f85eb..229c244b26 100644
> --- a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyEku.c
> +++ b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyEku.c
> @@ -111,7 +111,7 @@ Exit:
>    //
>    // Release Resources
>    //
> -  if (Signers) {
> +  if (Signers != NULL) {
>      sk_X509_free (Signers);
>    }
> 
> @@ -230,11 +230,11 @@ Exit:
>    //
>    // Release Resources
>    //
> -  if (ClonedCert) {
> +  if (ClonedCert != NULL) {
>      X509_free (ClonedCert);
>    }
> 
> -  if (Eku) {
> +  if (Eku != NULL) {
>      sk_ASN1_OBJECT_pop_free (Eku, ASN1_OBJECT_free);
>    }
> 
> @@ -281,13 +281,13 @@ CheckEKUs(
>      //
>      // Finding required EKU in cert.
>      //
> -    if (Asn1ToFind) {
> +    if (Asn1ToFind != NULL) {
>        ASN1_OBJECT_free(Asn1ToFind);
>        Asn1ToFind = NULL;
>      }
> 
>      Asn1ToFind = OBJ_txt2obj (RequiredEKUs[Index], 0);
> -    if (!Asn1ToFind) {
> +    if (Asn1ToFind == NULL) {
>        //
>        // Fail to convert required EKU to ASN1.
>        //
> @@ -313,7 +313,7 @@ CheckEKUs(
> 
>  Exit:
> 
> -  if (Asn1ToFind) {
> +  if (Asn1ToFind != NULL) {
>      ASN1_OBJECT_free(Asn1ToFind);
>    }
> 
> @@ -508,11 +508,11 @@ Exit:
>      free (SignedData);
>    }
> 
> -  if (SignerCert) {
> +  if (SignerCert != NULL) {
>      X509_free (SignerCert);
>    }
> 
> -  if (Pkcs7) {
> +  if (Pkcs7 != NULL) {
>      PKCS7_free (Pkcs7);
>    }
> 
> --
> 2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#44578): https://edk2.groups.io/g/devel/message/44578
Mute This Topic: https://groups.io/mt/32649746/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-