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 8733794148A for ; Tue, 27 Feb 2024 12:53:08 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=MJdVyih+k9Lp4Y/YJCL9BcBktzO5Af2oWFMROH80Hc0=; 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=1709038387; v=1; b=ujXW3/2xdDiXXONaSZyW70bsP9WTMQL3J4BP9g4EhFzK8oE+ESGgymadu8/mQ0CX2MlrdL0z 23A4vmJuBLqV87He7QY57X3bCQZ8D0A3wg2rf/4bZXYV80p9+pkAX1b/QQ1Uji7FWcgq3hY4NdI 8COQGb9txFfPUNWwSimJzQHE= X-Received: by 127.0.0.2 with SMTP id SPhfYY7687511xgXSi9u0cjS; Tue, 27 Feb 2024 04:53:07 -0800 X-Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.81]) by mx.groups.io with SMTP id smtpd.web11.11269.1709038386291831969 for ; Tue, 27 Feb 2024 04:53:06 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nEfS67Qhmg7WAEmtVpzoEmcCx09Ka2vbwBge74UewsFNusj8PXXVt+jb+w3sku3SPoI+gomfzNrgP0lFPqE4mKO+wuiImUEYVb3xtwoYrpz2mlhqTkW6w//Bk53Bum1VDkCMhc6Kyx4AWWd3GNTpVn5eaZxBnFT0RQUSgV0jMBLJ/zWYMU6kvnLt3JN3edbbR9tYorMJqHl9TSH13IygFpa0yAGpiWuxxondrdOhjAF0+lie0AWjihFIayij+Z29VZFCgnZUeByl7ZnuJND8udBYS3/ROcdAW3/KIX9oNDNW8eGQFT4llnWR1BGHHwELRaPdZQHXZTkemGh/54T1NA== 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=Gc+g0OhNR3w4+rQK/1cm2eL+gnA4L0a+JGbmbqYglbQ=; b=FbWVHt8rkWCf6DmnVejYZhwIdfOxscYKhNzvk8Arp9sKQ15qJyBc4Jn8NPD+ygrYR3UzQVlh3zW6t87xzVis+Kp810U+p3YB3BfJSXsDNu2uEz1mTp904RkVUqMtPvbDZ30gKkhT47hiossm552tbihDQB7zGUrpTT36QcfxQ7iixiTLFUz3EEKOTZTLd/6j/91DeVQzlNBShOs5JzeuQomIXwDLXDRYDJLKK9v80JPizmn7YYoI9y/b9BttNnQACFwTEyp85I+SH1QA6KYXWa4tQ2xs+bPjaguKTqjl3RPayQrFCdcvG4z/iz3K7nCg3M9Wk/13uIE5HBP/WDrczQ== 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 SJ0PR03CA0247.namprd03.prod.outlook.com (2603:10b6:a03:3a0::12) by SJ2PR12MB9138.namprd12.prod.outlook.com (2603:10b6:a03:565::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.36; Tue, 27 Feb 2024 12:53:03 +0000 X-Received: from SJ5PEPF000001D1.namprd05.prod.outlook.com (2603:10b6:a03:3a0:cafe::49) by SJ0PR03CA0247.outlook.office365.com (2603:10b6:a03:3a0::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.49 via Frontend Transport; Tue, 27 Feb 2024 12:53:03 +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 SJ5PEPF000001D1.mail.protection.outlook.com (10.167.242.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.25 via Frontend Transport; Tue, 27 Feb 2024 12:53:02 +0000 X-Received: from drhqmail201.nvidia.com (10.126.190.180) 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; Tue, 27 Feb 2024 04:52:49 -0800 X-Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Tue, 27 Feb 2024 04:52:49 -0800 X-Received: from NV-CL38DL3.nvidia.com (10.127.8.10) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Tue, 27 Feb 2024 04:52:48 -0800 From: "Nickle Wang via groups.io" To: CC: Abner Chang , Igor Kulchytskyy , "Nick Ramirez" Subject: [edk2-devel] [edk2-redfish-client][PATCH] RedfishClientPkg/ConverterLib: check JSON value type Date: Tue, 27 Feb 2024 20:52:47 +0800 Message-ID: <20240227125247.6934-1-nicklew@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001D1:EE_|SJ2PR12MB9138:EE_ X-MS-Office365-Filtering-Correlation-Id: 18ebccd4-42df-4078-eb08-08dc379308d5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: EISraCjd6JLom6uM2A3rV1h6qnjxiuojHE7Mo5HzG7dtG8ftpbQmKNs1hLUgYVNnjiJ5JAiIHSlDLqexZDX0bjPzvPjXWCEbvSnaNBzr0Ek9Pm521jPc7xPXYPqCZ7r4vI+IIljuXN6Thu3Qmy503RbVQUAjeQJwu2goNPjwURAH6fGJm4KwFIlXLgBJDB0ytR3AcUNlvZCYdAza0p2eMFaU2z/C61w8F7N5e2XuXmnY4HLEnPDLJDXn3Egv6BChsO9ta7oSdxUVTJ+xTKmM2zxREovdDYrFMF0JeFgdzO3ZdRAvSZ5Abyassap5iCfekV2UfSQuTtvmJJJl3o9lfgp5KOIYtAjyoVEYwpqKlL6xcyM2a6Ed4g5qISxdg3LxcsqXjnHqIu0FbyFG0F5G7wg9YCc7Pkq6VhwLf83XuBJleN9/fFFYIgUyPD2dSdaIuSEhwmRnxKwdCT/maqlFmKa6siR2zGJoIZ6YSBcgcDxSwa6C1K9b1/063TpcrS8B59LHl+IgreTKWu6AzYUtmvNIfnYaDUEUUO2VHmXOdF46bIUNBtqA0X0gCLgerLr2gWPJXcvdZYJ5d29CbNDbUZMbDFOZ69nSGiaPLvL/DcisU/vvTTbOYsWCB2rAU9YbdTK6HlpnLgHY70/bIcbl/UKYYCAXJ8niDL+7ue9wlldCn9tA/J1Y2jCxd7Pve0xs8w54IiLIljOGNF5/1cTzw0whZ7qz63pPmne0K+C9WiKcByl8iIX0dytwAwg+P4WWmOwGlSqupzw9FD90v1PuXbBsWxDnYApBMsaI9HjTJZo= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2024 12:53:02.7568 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 18ebccd4-42df-4078-eb08-08dc379308d5 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: SJ5PEPF000001D1.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB9138 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: D1kuAsPLhP58CLze2QtO6riDx7686176AA= 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="ujXW3/2x"; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Check and see if JSON object type is desired type before getting its value. According to the Redfish schema, attribute value can be null value. Add this error handling to avoid system assertion while getting attribute value. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Igor Kulchytskyy Cc: Nick Ramirez --- RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c b/RedfishC= lientPkg/ConverterLib/src/RedfishCsCommon.c index 250ef75e4..7ee3c86e1 100644 --- a/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c +++ b/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c @@ -1,5 +1,7 @@ /** @file =20 + Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved= . + Copyright Notice: Copyright 2019-2024 Distributed Management Task Force, Inc. All rights r= eserved. License: BSD 3-Clause License. For full text see link: https://github.co= m/DMTF/Redfish-JSON-C-Struct-Converter/blob/master/LICENSE.md @@ -829,6 +831,10 @@ GetRedfishPropertyStr ( return RedfishCS_status_not_found; } =20 + if (!json_is_string (TempJsonObj)) { + return RedfishCS_status_not_found; + } + Status =3D allocateDuplicateStr (Cs, (char *)json_string_value (TempJson= Obj), (void **)DstBuffer); return Status; } @@ -914,6 +920,10 @@ GetRedfishPropertyInt64 ( return Status; } =20 + if (!json_is_integer (TempJsonObj)) { + return RedfishCS_status_not_found; + } + **Dst =3D (RedfishCS_int64)json_integer_value (TempJsonObj); return RedfishCS_status_success; } --=20 2.34.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 (#116040): https://edk2.groups.io/g/devel/message/116040 Mute This Topic: https://groups.io/mt/104601599/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-