public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Chang, Abner via groups.io" <abner.chang=amd.com@groups.io>
To: Nickle Wang <nicklew@nvidia.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: Igor Kulchytskyy <igork@ami.com>, Nick Ramirez <nramirez@nvidia.com>
Subject: Re: [edk2-devel] [edk2-redfish-client][PATCH 6/6] RedfishClientPkg/RedfishFeatureUtilityLib: add string NULL check
Date: Tue, 28 Nov 2023 05:17:37 +0000	[thread overview]
Message-ID: <MN2PR12MB39667818AEA3A1B350C38A76EABCA@MN2PR12MB3966.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20231123143428.3724-1-nicklew@nvidia.com>

[AMD Official Use Only - General]

Reviewed-by: Abner Chang <abner.chang@amd.com>

> -----Original Message-----
> From: Nickle Wang <nicklew@nvidia.com>
> Sent: Thursday, November 23, 2023 10:34 PM
> To: devel@edk2.groups.io
> Cc: Chang, Abner <Abner.Chang@amd.com>; Igor Kulchytskyy
> <igork@ami.com>; Nick Ramirez <nramirez@nvidia.com>
> Subject: [edk2-redfish-client][PATCH 6/6]
> RedfishClientPkg/RedfishFeatureUtilityLib: add string NULL check
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> Add string NULL check in attribute comparison function and prevent
> NULL string assertion. This is not supposed to happen in normal
> condition so add error output for debugging purpose.
>
> Signed-off-by: Nickle Wang <nicklew@nvidia.com>
> Cc: Abner Chang <abner.chang@amd.com>
> Cc: Igor Kulchytskyy <igork@ami.com>
> Cc: Nick Ramirez <nramirez@nvidia.com>
> ---
>  .../RedfishFeatureUtilityLib.c                | 31 ++++++++++++++-----
>  1 file changed, 24 insertions(+), 7 deletions(-)
>
> diff --git
> a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.
> c
> b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.
> c
> index 753cd7b2..6652539c 100644
> ---
> a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.
> c
> +++
> b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.
> c
> @@ -3743,6 +3743,15 @@ CompareRedfishPropertyVagueValues (
>      // Loop through all key/value on Redfish service..
>      //
>      while (ThisRedfishVagueKeyValuePtr != NULL) {
> +      //
> +      // Empty attribute string check.
> +      //
> +      if (IS_EMPTY_STRING (ThisConfigVagueKeyValuePtr->KeyNamePtr) ||
> IS_EMPTY_STRING (ThisRedfishVagueKeyValuePtr->KeyNamePtr)) {
> +        DEBUG ((DEBUG_ERROR, "%a: empty attribute name detected!!\n",
> __func__));
> +        ThisRedfishVagueKeyValuePtr = ThisRedfishVagueKeyValuePtr-
> >NextKeyValuePtr;
> +        continue;
> +      }
> +
>        if (AsciiStrCmp (ThisConfigVagueKeyValuePtr->KeyNamePtr,
> ThisRedfishVagueKeyValuePtr->KeyNamePtr) == 0) {
>          //
>          // Check the type of value.
> @@ -3758,28 +3767,36 @@ CompareRedfishPropertyVagueValues (
>            //
>            // Is the string identical?
>            //
> -          if (AsciiStrCmp (
> -                ThisConfigVagueKeyValuePtr->Value->DataValue.CharPtr,
> -                ThisRedfishVagueKeyValuePtr->Value->DataValue.CharPtr
> -                ) == 0)
> -          {
> -            break;
> +          if ((ThisConfigVagueKeyValuePtr->Value->DataValue.CharPtr != NULL)
> && (ThisRedfishVagueKeyValuePtr->Value->DataValue.CharPtr != NULL)) {
> +            if (AsciiStrCmp (
> +                  ThisConfigVagueKeyValuePtr->Value->DataValue.CharPtr,
> +                  ThisRedfishVagueKeyValuePtr->Value->DataValue.CharPtr
> +                  ) == 0)
> +            {
> +              break;
> +            } else {
> +              DEBUG ((REDFISH_DEBUG_TRACE, "%a: %a is updated\n", __func__,
> ThisConfigVagueKeyValuePtr->KeyNamePtr));
> +              return FALSE;
> +            }
>            } else {
> -            return FALSE;
> +            DEBUG ((DEBUG_ERROR, "%a: NULL attribute (%a) value
> detected!!\n", __func__, ThisConfigVagueKeyValuePtr->KeyNamePtr));
>            }
>          } else if (ThisConfigVagueKeyValuePtr->Value->DataType ==
> RedfishCS_Vague_DataType_Int64) {
>            if (*ThisConfigVagueKeyValuePtr->Value->DataValue.Int64Ptr ==
> *ThisRedfishVagueKeyValuePtr->Value->DataValue.Int64Ptr) {
>              break;
>            } else {
> +            DEBUG ((REDFISH_DEBUG_TRACE, "%a: %a is updated\n", __func__,
> ThisConfigVagueKeyValuePtr->KeyNamePtr));
>              return FALSE;
>            }
>          } else if (ThisConfigVagueKeyValuePtr->Value->DataType ==
> RedfishCS_Vague_DataType_Bool) {
>            if ((UINT8)*ThisConfigVagueKeyValuePtr->Value->DataValue.BoolPtr ==
> (UINT8)*ThisRedfishVagueKeyValuePtr->Value->DataValue.BoolPtr) {
>              break;
>            } else {
> +            DEBUG ((REDFISH_DEBUG_TRACE, "%a: %a is updated\n", __func__,
> ThisConfigVagueKeyValuePtr->KeyNamePtr));
>              return FALSE;
>            }
>          } else {
> +          DEBUG ((REDFISH_DEBUG_TRACE, "%a: %a unsupported type: 0x%x\n",
> __func__, ThisConfigVagueKeyValuePtr->KeyNamePtr,
> ThisConfigVagueKeyValuePtr->Value->DataType));
>            return FALSE;
>          }
>        }
> --
> 2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111795): https://edk2.groups.io/g/devel/message/111795
Mute This Topic: https://groups.io/mt/102767547/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



      reply	other threads:[~2023-11-28  5:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-23 14:34 [edk2-devel] [edk2-redfish-client][PATCH 6/6] RedfishClientPkg/RedfishFeatureUtilityLib: add string NULL check Nickle Wang via groups.io
2023-11-28  5:17 ` Chang, Abner via groups.io [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MN2PR12MB39667818AEA3A1B350C38A76EABCA@MN2PR12MB3966.namprd12.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox