From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 4D686AC12C5 for ; Thu, 23 Nov 2023 14:34:39 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=hlntkeCO93e6SRBDlJ/M/r/U/0tkAPTl7Wq9h4cZJB4=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Received-SPF:From:To:CC:Subject:Date:Message-ID:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1700750078; v=1; b=DYTjX8FSYKUolGJ3DJ5qBQfb5oIEvhNqyveWkKRGGuV1u80EQuoOAl/uMIHGlo1JbdMMPOfn 2fM4xd8HnOhyVkwB9s3sU1RQc8Z1axjVDV76dbUPJuYNgNtus6lXZSq++k3/1iLlv1xQeFgo/IV wtbZmN7tfg15gblNawTKRPwE= X-Received: by 127.0.0.2 with SMTP id XO54YY7687511xcTe1UGzN1x; Thu, 23 Nov 2023 06:34:38 -0800 X-Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.78]) by mx.groups.io with SMTP id smtpd.web10.91977.1700750077486062590 for ; Thu, 23 Nov 2023 06:34:37 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bZ4YNB8jPbZp/pk7uMhDG8NXDnia7/UqjBeczpN+PmhdnnkPtxsnguC0PSEMrmz/ppbfkXUN7NeVr1g+QGvZJLYIv1XyJAdOAiQkfzg1wbktNSySaAcJd61yWy7hjVXCnvSEKLQfSgz45W2YWJf47zFLBQc0wi3vXU0nyyuc9I6LFxLlV+0HoOtftSU+ltJhB80T7KvgAkBz+xw3QEtzYf8SnHjCZdxkshQLeW2v5zegZN3gsR/C3UgmWkowJfw0LsDBaCt7zm3Hc4TCmk9zT8FoLImrXJP6jssGOa82KTgglBIg5rZORfLwH3fQouXa2e1TuOPf3Nazxt+ikE4tQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=J3wTvj01/7Uw15NpPvGumBk5ZLrhQsb63SFXVt+2gT0=; b=NLRNEj97EAB1hIafETDlRCTAuHGqIz2qGbdwqdPh5kBdoc+JoEyUK9LbP/ABsFpdT6mZtF/ZHXYb5LoyxLCJWnXNnRaHjBTYpOUx85Jn/sIuBQP+WuKipyql1URwlCV1f+5/iINVL2r6wQsM2IvBuq4Mf2z23FNVSmnIDDfyLYGi5+H7F/8RN05QTERcYNuPMjknV0bQ+g6OxBK+KfLmqTsXRUtO7OrR2ARxkaJcnEONvID5skrFv8tQjLn7CFfl6PMRVp7hZBmvhclQ85JHFPDuGbOpxLTUnLKY5StKv9J6yoenHwv2606SyJa18+mpGSrY5880Dhesr5vTahbQzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) X-Received: from CH2PR16CA0009.namprd16.prod.outlook.com (2603:10b6:610:50::19) by CH2PR12MB4135.namprd12.prod.outlook.com (2603:10b6:610:7c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.20; Thu, 23 Nov 2023 14:34:32 +0000 X-Received: from DS3PEPF000099D4.namprd04.prod.outlook.com (2603:10b6:610:50:cafe::ae) by CH2PR16CA0009.outlook.office365.com (2603:10b6:610:50::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.19 via Frontend Transport; Thu, 23 Nov 2023 14:34:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C X-Received: from mail.nvidia.com (216.228.118.233) by DS3PEPF000099D4.mail.protection.outlook.com (10.167.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.12 via Frontend Transport; Thu, 23 Nov 2023 14:34:32 +0000 X-Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 23 Nov 2023 06:34:30 -0800 X-Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 23 Nov 2023 06:34:29 -0800 X-Received: from NV-CL38DL3.nvidia.com (10.127.8.12) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Thu, 23 Nov 2023 06:34:28 -0800 From: "Nickle Wang via groups.io" To: CC: Abner Chang , Igor Kulchytskyy , "Nick Ramirez" Subject: [edk2-devel] [edk2-redfish-client][PATCH 6/6] RedfishClientPkg/RedfishFeatureUtilityLib: add string NULL check Date: Thu, 23 Nov 2023 22:34:28 +0800 Message-ID: <20231123143428.3724-1-nicklew@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099D4:EE_|CH2PR12MB4135:EE_ X-MS-Office365-Filtering-Correlation-Id: d45efcb1-ea99-44c0-7273-08dbec314eee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: zyFgHBgsopdninNYrw9iQO4qVNtjt5fWEMj+rawbD4Np9glL7AgdC3D6lFYW7/VCnyk2de6en7bZv7ms6hTVyCXjtqhre9iaw7Vnv1X7Ak4YlKr6qekBLaHXwISrmE6LSCsmWw2k8wp/iO7aEBfzi1aouWrUqrMwDDIOb1Ah1e+WLiRRoQc9CGN1AUXTqNyibkn19ulM0eCTsxCLCjEyjvdmhi0pS9gySUVY4/+txcWqiRqAFoTBm50UrhlmOG43r0G2BdL6UCu7SuX+5dS9AotN0CALZoFtzRVg96MBO7wNJzHmWlfgJvWeqpG9qG3vUorOWdXeJf8c6vdivFkHWDel3hnFRHyoYSUKXJ11KVuELuRHR/ULT84ygUlmbFaB7We3H6513DEyVFNDAm5KdXOZPp2ukvAwVoYumwFjztDoqwFpEJ2aXhOMQvTqjqQjQyfiSmYv7IL86kW4VWmEMj7Ww3iAOGxK3a6PDARhmShhxOIzkZcjXRTcvNH5awr6X9why/wHCAm40WOK15NoThYgUDUdpilrSl1lMpM5ZrtLC/A6Lz0Jxed/Cmzfk9XFJ4tVAE7WGnMLv1MD21uaAObUfg+SXERBju2PETQ9MTOfST54KjNZC72dDZQ7WccQlsGThQPpavL6HuxNOe4T67NbjBSr38I5jsfWlmXz4NjQaZLVIPwRj0NZLPXTblI/TOdpGV/Zput1XW1MW4ivvY4JjmnRlISMrBeF9M8wyEl2GhTYgCs3ZuBPTPjlcH9L X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2023 14:34:32.3609 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d45efcb1-ea99-44c0-7273-08dbec314eee X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099D4.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4135 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,nicklew@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: jg7dsjlsXa9MFAWjEsaw0Hldx7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-Spam-Flag: yes X-Spam-Level: ************ X-GND-Spam-Score: 190 X-GND-Status: SPAM Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=DYTjX8FS; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io 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 Cc: Abner Chang Cc: Igor Kulchytskyy Cc: Nick Ramirez --- .../RedfishFeatureUtilityLib.c | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatu= reUtilityLib.c b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishF= eatureUtilityLib.c index 753cd7b2..6652539c 100644 --- a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib.c +++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtili= tyLib.c @@ -3743,6 +3743,15 @@ CompareRedfishPropertyVagueValues ( // Loop through all key/value on Redfish service.. // while (ThisRedfishVagueKeyValuePtr !=3D NULL) { + // + // Empty attribute string check. + // + if (IS_EMPTY_STRING (ThisConfigVagueKeyValuePtr->KeyNamePtr) || IS_E= MPTY_STRING (ThisRedfishVagueKeyValuePtr->KeyNamePtr)) { + DEBUG ((DEBUG_ERROR, "%a: empty attribute name detected!!\n", __fu= nc__)); + ThisRedfishVagueKeyValuePtr =3D ThisRedfishVagueKeyValuePtr->NextK= eyValuePtr; + continue; + } + if (AsciiStrCmp (ThisConfigVagueKeyValuePtr->KeyNamePtr, ThisRedfish= VagueKeyValuePtr->KeyNamePtr) =3D=3D 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 - ) =3D=3D 0) - { - break; + if ((ThisConfigVagueKeyValuePtr->Value->DataValue.CharPtr !=3D N= ULL) && (ThisRedfishVagueKeyValuePtr->Value->DataValue.CharPtr !=3D NULL)) = { + if (AsciiStrCmp ( + ThisConfigVagueKeyValuePtr->Value->DataValue.CharPtr, + ThisRedfishVagueKeyValuePtr->Value->DataValue.CharPtr + ) =3D=3D 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 =3D=3D Redf= ishCS_Vague_DataType_Int64) { if (*ThisConfigVagueKeyValuePtr->Value->DataValue.Int64Ptr =3D= =3D *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 =3D=3D Redf= ishCS_Vague_DataType_Bool) { if ((UINT8)*ThisConfigVagueKeyValuePtr->Value->DataValue.BoolPtr= =3D=3D (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, ThisConfigVagueKeyValuePt= r->Value->DataType)); return FALSE; } } --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111675): https://edk2.groups.io/g/devel/message/111675 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] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-