From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web10.4890.1669791407368834926 for ; Tue, 29 Nov 2022 22:56:47 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=bWdE1QgH; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: zhichao.gao@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669791407; x=1701327407; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=CEjLvVCDeDerKgTguOgdb6anE5I5OKb9gLSa7fxNINQ=; b=bWdE1QgH+yy3UYQwUV2Tlr9ByOXjlvoObxuNxWEcY2PbBYALAdwvtG8k VGgno0Ass2KaoGbjIPN1QmZXD3w9lAcZIkNW6i/wO/fgOil8Y5dQhBgIj Ia6f5VeA2wbyK3Ar09ItX0kD/mMw9+TnjM8xmXipSZgDyhrtGkmopnOul F+SleZcu0XLqjIkUTy2iurZtLHMmb/rKdlq3EBsr2oN6WFShTnRW7K7sT FdUxrwwpxTAgz8Hsqt7tFftfHTpW8aecCOS13gV4UGSzeeaIckxIWThmg yMwMt1a4S04NhbCoD+21efiJAOCCwbVnEPP2VwLXnYtdm1qRcYxNK8YpR A==; X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="298691838" X-IronPort-AV: E=Sophos;i="5.96,205,1665471600"; d="scan'208";a="298691838" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2022 22:55:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="646219074" X-IronPort-AV: E=Sophos;i="5.96,205,1665471600"; d="scan'208";a="646219074" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmsmga007.fm.intel.com with ESMTP; 29 Nov 2022 22:55:40 -0800 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 29 Nov 2022 22:55:40 -0800 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 29 Nov 2022 22:55:40 -0800 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16 via Frontend Transport; Tue, 29 Nov 2022 22:55:40 -0800 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.169) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.16; Tue, 29 Nov 2022 22:55:39 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fUzuW9yfhV2DxKfdi8+tJ0E6f5WM/cZBHCQifHv6p2lq8B9y9Gicj4f/G+mAc1AnjmjSS93RITcP5OodbKi4vL0JzCl8/mKca13M12nNPXGhuLZJp2p8SGhLM9VKWmvWT3nmMKMOsnqTq1QU9bHWhgM2IIpKRBh+kpNxvS8o4n4etPcEWQZGglC0V8/NZV8mpXdEM3RH/VySDXNVqNmMGSgfAIpDvuqWw7E5hu43fkLfJOQRgSTKgwJZIFS3GSTzfsTkNqv+CgbF+mFl+WZt9NSrlZfKuqebsWp/A2myJO5VwKObpa+F9Q1ha8IVSd6aUc1McJ67h/kOVN5iJyBncA== 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=5MoipA+uNKb22vNliv/Dk2dz+CmKchli649+lV6448E=; b=TGi/m6qCUJEGCU3invj8YfgcyQ8gt6MW568KjuM02IdIC1R0ZrbOnpv+Y0XWce0AjIMsepS0VXFnxl+hX0UeCo1uIE3x8GCrdQ07RY9+2owcAi0Vk447wnGzNbkTCZ06V1p37vL9unk8Zt0g0kyn6okfwDRq2v1pEl7GW6EJRcR314X04KR9LO7Qlq0guXANv560r3g3On1T1FdYeFg8a38ZB8yMu7gc1FJmZf59qOFylYNmQwnMF1Lt8schY4RgyFpTLBk0/MyIqwFwMO2Qw/+mlSISKHN+VZGgJWzsZ2BX31L7+F7rR0eyeyofYtJ0bdtTDTTgYfo4bSRfrAzmgA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from PH7PR11MB6377.namprd11.prod.outlook.com (2603:10b6:510:1fb::13) by PH0PR11MB7421.namprd11.prod.outlook.com (2603:10b6:510:281::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Wed, 30 Nov 2022 06:55:37 +0000 Received: from PH7PR11MB6377.namprd11.prod.outlook.com ([fe80::6a3:d470:3867:1403]) by PH7PR11MB6377.namprd11.prod.outlook.com ([fe80::6a3:d470:3867:1403%5]) with mapi id 15.20.5857.023; Wed, 30 Nov 2022 06:55:37 +0000 From: "Gao, Zhichao" To: "mikuback@linux.microsoft.com" , "devel@edk2.groups.io" CC: Erich McMillan , "Kinney, Michael D" , "Ni, Ray" Subject: Re: [PATCH v2 09/12] ShellPkg: Fix conditionally uninitialized variables Thread-Topic: [PATCH v2 09/12] ShellPkg: Fix conditionally uninitialized variables Thread-Index: AQHZBBjGRXlR3zf+J0uqHoewZSVl6a5XCTgw Date: Wed, 30 Nov 2022 06:55:37 +0000 Message-ID: References: <20221129173246.2182-1-mikuback@linux.microsoft.com> <20221129173246.2182-10-mikuback@linux.microsoft.com> In-Reply-To: <20221129173246.2182-10-mikuback@linux.microsoft.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PH7PR11MB6377:EE_|PH0PR11MB7421:EE_ x-ms-office365-filtering-correlation-id: 050bca9c-2878-4508-accd-08dad29fe2ef x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: rCyGjWQiodw6xmW2e8thFtj8xL+vQ+r0tWeEZpHTUmnWflAQJlOn3KtKGpJK7z6S0AhFL+Q/AWBuIwg4fr+stUdm1uE+r00QZLfwenm/Zuz1WLcqNhvTRwB2Ry19kPpvK21WvPPhGj8x8r3FG01X9kOslJso91gFPsyQmBwMbQpptCGImUzeSayfCUMUa0EFiJkyDi/x0LiMr6OYrE2tDbWA7CrbXmhXF7ojmisz5Ougtf7y6DVQFCQAQH/mw45zTtICtpLCzzau5rAbyiGIz5PcZ0kj8STDD375lUbBLUGSK3tvg8mUhF8QaYwNMKf/nkv17OY6jFe3dRtZZUnKcsjamsX6hnPfgSwuoMyF1PxJOzRttJtssR+4iit30F/yr3m36HuNXU+vD1VuQNCE+lZFVz9209lNKTaAxKjjJ7gqCRvsFtX3/9NkMzGuClcRRxuM9G0n5eekEgFSvOShsVErlY7xlsqmvxOhp3EzjQn3qN7WRXc/rWuuOtzzxGQEppHZyrj5JhJZlnf0AcNheB2x7Mu2w79mAyU/ekyobs7MouxvTe+UxsmqYRpc6jmOlaNOOZeACXPPR/2ldH8DOxQ6NJJ2UQxrEFm2gp5KlEntiQO+bUTgRgNOrrZ2lKqgjzUfvV7Pn172rO9cmyv2T7CJHQCJKOEsrvcMc1DgxQau+8+q42qriH/+sFUt/bqVTMgaAPDSdJFzTkoYxEHKjc9+HPfEd6sGK1gEBZgF0lo= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH7PR11MB6377.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(366004)(376002)(39860400002)(346002)(136003)(451199015)(86362001)(33656002)(55016003)(41300700001)(316002)(5660300002)(107886003)(66476007)(83380400001)(8676002)(76116006)(66946007)(66446008)(4326008)(26005)(110136005)(7696005)(71200400001)(64756008)(53546011)(9686003)(6506007)(66556008)(54906003)(186003)(19627235002)(38070700005)(966005)(478600001)(82960400001)(52536014)(122000001)(30864003)(8936002)(2906002)(38100700002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?xivjLZdzUR4SO/vA0x8/aUqiAYABW1nknqrETamLsybLPzrV0FCrtQeI1uj5?= =?us-ascii?Q?POMgj3qQLFBZOCtd48ireNeOUc6NwKRHeSB/IQb9+coMnMes7XyNwNB1GCJ8?= =?us-ascii?Q?lFSDLlSkYMqBuvewaOZzr86AvJopikXmjIRKyMVdAz4VkT00GDavLLRzbygU?= =?us-ascii?Q?zDpKY0ACzX8RgNQXpGCSCi5tTxDavJmBDdB78m96t8hP8pT0kfQ9csagzDl0?= =?us-ascii?Q?+V+sPE/lzZO/CDp7PJZOqGCtIOqM6hXNrKHU6P0Zv94FIbigeYWxuPW0Z4eX?= =?us-ascii?Q?g2Qen5OWzZzc4FtfP/1vhzocp4IOHLC25PWv3U1apZdqrgczWP+BE3SAMVaD?= =?us-ascii?Q?/SyIzJ0Kq61cNsRvfXF/ls/oEsXlGTRZ/vkbS5QIlg19Ooecvl1skmZHJB21?= =?us-ascii?Q?G6vcxhhRdNYkI8eHCk10olPm2W4hOgONczMcexxKb36iXV/KGT4+UU09kmyk?= =?us-ascii?Q?/TCImQpu7naBpHZ88sq+mm3bNZO5rJXF3xq6G/PHh1EVofoE342qG6H64x04?= =?us-ascii?Q?BkASBVNw2RqZlmMq170tCyX2bAuLW2ypWE2j0VLiR9PDrgRVVeEv9Kze7Kzk?= =?us-ascii?Q?4U2mGwgDxJTUl5J9M7+sb0iNlYV62xOFuxLncpBtYZwxH2MkOlRMpvs6ZS6L?= =?us-ascii?Q?8Vlwjjr4of9ysFsTnN9+BH+IotqPejhdMfxv7y39g/t1d4zX9y1RbOAlY3EV?= =?us-ascii?Q?F5OnbveZwKuq32D8qmMjKxlZpvkSIFfY3ioVtM/n0/PMRDrq5jI8gq8+9v/s?= =?us-ascii?Q?FPseB59SCl6XOsCSDPdQSOzrFkMH8vV6Ks/6Vwo3GpOmWtyNv2KHKoBuHraU?= =?us-ascii?Q?8Gy/P79hhk5fEvOR/kvmfSekaAZwYMEh3h3b+nwvYlOD1LjEBZIq0pC4oz8/?= =?us-ascii?Q?ZOHQ3ihg+IDLQDfE+5D9w0nHTjvQb2o1N3n0yhivJFaZD2BDAyBdQeLSZFek?= =?us-ascii?Q?/6LCI6LQgc7AOHN2if0gPrOxeZ93JAwsu9J/yLU+Yz5iy0XciTo6id8nb0Ib?= =?us-ascii?Q?XMV53Sop4kkm4iAI3wwJZFe52JlRUkCSql/PWtt7vvyYJ2+JiatGHzQn68mF?= =?us-ascii?Q?y9qxDekZqQ793LpYHyTPI7226ZKhDBM5M/yoXmV4uq3de80rRPVPURET270l?= =?us-ascii?Q?l9vV6JILFEQIrrXu6VuHUZ7VNEl9KFtw0zVTpO/5kNgf6ywzgE1exxB0xIku?= =?us-ascii?Q?kKvzmxQGAbUImjUIYj4Naw8aDhVaFmToIuvMzgPhMUjQPhBSq0/8ub1QcnrG?= =?us-ascii?Q?AB6LdblOpLn2eBeUB6KDbWvT+JnhoIT3PWHcB+FCBDPiybJ0KoYAD7Wr9+Z7?= =?us-ascii?Q?cRIeHDia0Jac54aqqNpocIk2UzXD8DEZdFzdpeWuvlqC0wmCDUDxQoxV0haV?= =?us-ascii?Q?wnXQaIVXy7n/r3NknZtd8dhJXyRee5qsgsFtd3NLplu+h6Mb4wimav7YEvP3?= =?us-ascii?Q?fSxXOlvzwbt4H+thb28siQdGDU4+nsbPZAkG18TEFzxGmdT1zquEvrdCDZE3?= =?us-ascii?Q?uCXE6UZ1bQLaEM/bXFr8DSnKYlaq3sHo6cq6WuZXJkYxM+NBJNI0mpBfbnEG?= =?us-ascii?Q?r3js7aQP4pofG7Nt15CsI+Q2r58N53LRYbvMUfZ3?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH7PR11MB6377.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 050bca9c-2878-4508-accd-08dad29fe2ef X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Nov 2022 06:55:37.4256 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 272fM6RFcE9M8LBdM6MVgJmUeBjrCpeG+rZHZa0c98mTx3MZ8S5KZtCUYBnLikRX/51VroA4AQSaU853FS1iVQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB7421 Return-Path: zhichao.gao@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Zhichao Gao Thanks, Zhichao > -----Original Message----- > From: mikuback@linux.microsoft.com > Sent: Wednesday, November 30, 2022 1:33 AM > To: devel@edk2.groups.io > Cc: Erich McMillan ; Kinney, Michael D > ; Michael Kubacki > ; Ni, Ray ; Gao, Zhichao > > Subject: [PATCH v2 09/12] ShellPkg: Fix conditionally uninitialized varia= bles >=20 > From: Michael Kubacki >=20 > Fixes CodeQL alerts for CWE-457: > https://cwe.mitre.org/data/definitions/457.html >=20 > Cc: Erich McMillan > Cc: Michael D Kinney > Cc: Michael Kubacki > Cc: Ray Ni > Cc: Zhichao Gao > Co-authored-by: Erich McMillan > Signed-off-by: Michael Kubacki > --- > ShellPkg/Application/Shell/Shell.c | 1 + > ShellPkg/Application/Shell/ShellProtocol.c | 60 +++++++= +++---------- > ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c | 56 > +++++++++--------- > ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c | 18 +++--- > ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c | 9 ++- > ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c | 14 +++-- > ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c | 17 ++++-- > ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c | 21 +++---- > 8 files changed, 107 insertions(+), 89 deletions(-) >=20 > diff --git a/ShellPkg/Application/Shell/Shell.c > b/ShellPkg/Application/Shell/Shell.c > index df00adfdfa5b..89a677a32978 100644 > --- a/ShellPkg/Application/Shell/Shell.c > +++ b/ShellPkg/Application/Shell/Shell.c > @@ -1300,6 +1300,7 @@ DoStartupScript ( > CHAR16 *FullFileStringPath; > UINTN NewSize; >=20 > + CalleeStatus =3D EFI_SUCCESS; > Key.UnicodeChar =3D CHAR_NULL; > Key.ScanCode =3D 0; >=20 > diff --git a/ShellPkg/Application/Shell/ShellProtocol.c > b/ShellPkg/Application/Shell/ShellProtocol.c > index 509eb60e40f4..d04b47538b96 100644 > --- a/ShellPkg/Application/Shell/ShellProtocol.c > +++ b/ShellPkg/Application/Shell/ShellProtocol.c > @@ -729,50 +729,52 @@ EfiShellGetDeviceName ( > // > // Now check the parent controller using this as the child. > // > - if (DeviceNameToReturn =3D=3D NULL) { > - PARSE_HANDLE_DATABASE_PARENTS (DeviceHandle, > &ParentControllerCount, &ParentControllerBuffer); > + Status =3D PARSE_HANDLE_DATABASE_PARENTS (DeviceHandle, > &ParentControllerCount, &ParentControllerBuffer); > + if ((DeviceNameToReturn =3D=3D NULL) && !EFI_ERROR (Status)) { > for (LoopVar =3D 0; LoopVar < ParentControllerCount; LoopVar++) { > - PARSE_HANDLE_DATABASE_UEFI_DRIVERS > (ParentControllerBuffer[LoopVar], &ParentDriverCount, > &ParentDriverBuffer); > - for (HandleCount =3D 0; HandleCount < ParentDriverCount; > HandleCount++) { > - // > - // try using that driver's component name with controller and = our > driver as the child. > - // > - Status =3D gBS->OpenProtocol ( > - ParentDriverBuffer[HandleCount], > - &gEfiComponentName2ProtocolGuid, > - (VOID **)&CompName2, > - gImageHandle, > - NULL, > - EFI_OPEN_PROTOCOL_GET_PROTOCOL > - ); > - if (EFI_ERROR (Status)) { > + Status =3D PARSE_HANDLE_DATABASE_UEFI_DRIVERS > (ParentControllerBuffer[LoopVar], &ParentDriverCount, > &ParentDriverBuffer); > + if (!EFI_ERROR (Status)) { > + for (HandleCount =3D 0; HandleCount < ParentDriverCount; > HandleCount++) { > + // > + // try using that driver's component name with controller an= d our > driver as the child. > + // > Status =3D gBS->OpenProtocol ( > ParentDriverBuffer[HandleCount], > - &gEfiComponentNameProtocolGuid, > + &gEfiComponentName2ProtocolGuid, > (VOID **)&CompName2, > gImageHandle, > NULL, > EFI_OPEN_PROTOCOL_GET_PROTOCOL > ); > - } > + if (EFI_ERROR (Status)) { > + Status =3D gBS->OpenProtocol ( > + ParentDriverBuffer[HandleCount], > + &gEfiComponentNameProtocolGuid, > + (VOID **)&CompName2, > + gImageHandle, > + NULL, > + EFI_OPEN_PROTOCOL_GET_PROTOCOL > + ); > + } > + > + if (EFI_ERROR (Status)) { > + continue; > + } >=20 > - if (EFI_ERROR (Status)) { > - continue; > + Lang =3D GetBestLanguageForDriver (CompName2- > >SupportedLanguages, Language, FALSE); > + Status =3D CompName2->GetControllerName (CompName2, > ParentControllerBuffer[LoopVar], DeviceHandle, Lang, > &DeviceNameToReturn); > + FreePool (Lang); > + Lang =3D NULL; > + if (!EFI_ERROR (Status) && (DeviceNameToReturn !=3D NULL)) { > + break; > + } > } >=20 > - Lang =3D GetBestLanguageForDriver (CompName2- > >SupportedLanguages, Language, FALSE); > - Status =3D CompName2->GetControllerName (CompName2, > ParentControllerBuffer[LoopVar], DeviceHandle, Lang, > &DeviceNameToReturn); > - FreePool (Lang); > - Lang =3D NULL; > + SHELL_FREE_NON_NULL (ParentDriverBuffer); > if (!EFI_ERROR (Status) && (DeviceNameToReturn !=3D NULL)) { > break; > } > } > - > - SHELL_FREE_NON_NULL (ParentDriverBuffer); > - if (!EFI_ERROR (Status) && (DeviceNameToReturn !=3D NULL)) { > - break; > - } > } >=20 > SHELL_FREE_NON_NULL (ParentControllerBuffer); diff --git > a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c > b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c > index 36cf46fb2c38..4549cbde9b9a 100644 > --- a/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c > +++ b/ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c > @@ -1399,10 +1399,11 @@ ShellCommandCreateInitialMappingsAndPaths ( > CHAR16 *MapName; > SHELL_MAP_LIST *MapListItem; >=20 > - SplitCurDir =3D NULL; > - MapName =3D NULL; > - MapListItem =3D NULL; > - HandleList =3D NULL; > + ConsistMappingTable =3D NULL; > + SplitCurDir =3D NULL; > + MapName =3D NULL; > + MapListItem =3D NULL; > + HandleList =3D NULL; >=20 > // > // Reset the static members back to zero @@ -1458,32 +1459,35 @@ > ShellCommandCreateInitialMappingsAndPaths ( > // > PerformQuickSort (DevicePathList, Count, sizeof > (EFI_DEVICE_PATH_PROTOCOL *), DevicePathCompare); >=20 > - ShellCommandConsistMappingInitialize (&ConsistMappingTable); > - // > - // Assign new Mappings to all... > - // > - for (Count =3D 0; HandleList[Count] !=3D NULL; Count++) { > + if (!EFI_ERROR (ShellCommandConsistMappingInitialize > + (&ConsistMappingTable))) { > // > - // Get default name first > + // Assign new Mappings to all... > // > - NewDefaultName =3D ShellCommandCreateNewMappingName > (MappingTypeFileSystem); > - ASSERT (NewDefaultName !=3D NULL); > - Status =3D ShellCommandAddMapItemAndUpdatePath (NewDefaultName, > DevicePathList[Count], 0, TRUE); > - ASSERT_EFI_ERROR (Status); > - FreePool (NewDefaultName); > - > - // > - // Now do consistent name > - // > - NewConsistName =3D ShellCommandConsistMappingGenMappingName > (DevicePathList[Count], ConsistMappingTable); > - if (NewConsistName !=3D NULL) { > - Status =3D ShellCommandAddMapItemAndUpdatePath > (NewConsistName, DevicePathList[Count], 0, FALSE); > + for (Count =3D 0; HandleList[Count] !=3D NULL; Count++) { > + // > + // Get default name first > + // > + NewDefaultName =3D ShellCommandCreateNewMappingName > (MappingTypeFileSystem); > + ASSERT (NewDefaultName !=3D NULL); > + Status =3D ShellCommandAddMapItemAndUpdatePath > (NewDefaultName, > + DevicePathList[Count], 0, TRUE); > ASSERT_EFI_ERROR (Status); > - FreePool (NewConsistName); > + FreePool (NewDefaultName); > + > + // > + // Now do consistent name > + // > + NewConsistName =3D ShellCommandConsistMappingGenMappingName > (DevicePathList[Count], ConsistMappingTable); > + if (NewConsistName !=3D NULL) { > + Status =3D ShellCommandAddMapItemAndUpdatePath > (NewConsistName, DevicePathList[Count], 0, FALSE); > + ASSERT_EFI_ERROR (Status); > + FreePool (NewConsistName); > + } > } > } >=20 > - ShellCommandConsistMappingUnInitialize (ConsistMappingTable); > + if (ConsistMappingTable !=3D NULL) { > + ShellCommandConsistMappingUnInitialize (ConsistMappingTable); > + } >=20 > SHELL_FREE_NON_NULL (HandleList); > SHELL_FREE_NON_NULL (DevicePathList); @@ -1626,12 +1630,12 @@ > ShellCommandUpdateMapping ( > // > PerformQuickSort (DevicePathList, Count, sizeof > (EFI_DEVICE_PATH_PROTOCOL *), DevicePathCompare); >=20 > - ShellCommandConsistMappingInitialize (&ConsistMappingTable); > + Status =3D ShellCommandConsistMappingInitialize > + (&ConsistMappingTable); >=20 > // > // Assign new Mappings to remainders > // > - for (Count =3D 0; !EFI_ERROR (Status) && HandleList[Count] !=3D NULL > && !EFI_ERROR (Status); Count++) { > + for (Count =3D 0; !EFI_ERROR (Status) && HandleList[Count] !=3D NULL= ; > + Count++) { > // > // Skip ones that already have > // > diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c > b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c > index 97a4b57a932f..5329b559ba46 100644 > --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c > +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c > @@ -158,7 +158,10 @@ ShellCommandRunDblk ( > ShellStatus =3D SHELL_INVALID_PARAMETER; > } >=20 > - ShellConvertStringToUint64 (LbaString, &Lba, TRUE, FALSE); > + if (EFI_ERROR (ShellConvertStringToUint64 (LbaString, &Lba, TRUE= , > FALSE))) { > + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV= ), > gShellDebug1HiiHandle, L"dblk", LbaString); > + ShellStatus =3D SHELL_INVALID_PARAMETER; > + } > } >=20 > if (BlockCountString =3D=3D NULL) { > @@ -169,12 +172,13 @@ ShellCommandRunDblk ( > ShellStatus =3D SHELL_INVALID_PARAMETER; > } >=20 > - ShellConvertStringToUint64 (BlockCountString, &BlockCount, TRUE, > FALSE); > - if (BlockCount > 0x10) { > - BlockCount =3D 0x10; > - } else if (BlockCount =3D=3D 0) { > - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV= ), > gShellDebug1HiiHandle, L"dblk", BlockCountString); > - ShellStatus =3D SHELL_INVALID_PARAMETER; > + if (!EFI_ERROR (ShellConvertStringToUint64 (BlockCountString, > &BlockCount, TRUE, FALSE))) { > + if (BlockCount > 0x10) { > + BlockCount =3D 0x10; > + } else if (BlockCount =3D=3D 0) { > + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_I= NV), > gShellDebug1HiiHandle, L"dblk", BlockCountString); > + ShellStatus =3D SHELL_INVALID_PARAMETER; > + } > } > } >=20 > diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c > b/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c > index 8bf23a2076a1..72f8c087cb69 100644 > --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c > +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c > @@ -112,10 +112,13 @@ ShellCommandRunEfiDecompress ( >=20 > if (ShellStatus =3D=3D SHELL_SUCCESS) { > Status =3D FileHandleGetSize (InFileHandle, &Temp64Bit); > - ASSERT (Temp64Bit <=3D (UINT32)(-1)); > - InSize =3D (UINTN)Temp64Bit; > ASSERT_EFI_ERROR (Status); > - InBuffer =3D AllocateZeroPool (InSize); > + if (!EFI_ERROR (Status)) { > + ASSERT (Temp64Bit <=3D (UINT32)(-1)); > + InSize =3D (UINTN)Temp64Bit; > + InBuffer =3D AllocateZeroPool (InSize); > + } > + > if (InBuffer =3D=3D NULL) { > Status =3D EFI_OUT_OF_RESOURCES; > } else { > diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c > b/ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c > index d7a133c0c5b4..870c5b0d1da7 100644 > --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c > +++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c > @@ -508,9 +508,10 @@ ShellCommandRunConnect ( > Count =3D ShellCommandLineGetCount (Package); >=20 > if (Param1 !=3D NULL) { > - Status =3D ShellConvertStringToUint64 (Param1, &Intermediate, T= RUE, > FALSE); > - Handle1 =3D ConvertHandleIndexToHandle ((UINTN)Intermediate); > - if (EFI_ERROR (Status)) { > + Status =3D ShellConvertStringToUint64 (Param1, &Intermediate, TR= UE, > FALSE); > + if (!EFI_ERROR (Status)) { > + Handle1 =3D ConvertHandleIndexToHandle ((UINTN)Intermediate); > + } else { > ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDL= E), > gShellDriver1HiiHandle, L"connect", Param1); > ShellStatus =3D SHELL_INVALID_PARAMETER; > } > @@ -519,9 +520,10 @@ ShellCommandRunConnect ( > } >=20 > if (Param2 !=3D NULL) { > - Status =3D ShellConvertStringToUint64 (Param2, &Intermediate, T= RUE, > FALSE); > - Handle2 =3D ConvertHandleIndexToHandle ((UINTN)Intermediate); > - if (EFI_ERROR (Status)) { > + Status =3D ShellConvertStringToUint64 (Param2, &Intermediate, TR= UE, > FALSE); > + if (!EFI_ERROR (Status)) { > + Handle2 =3D ConvertHandleIndexToHandle ((UINTN)Intermediate); > + } else { > ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDL= E), > gShellDriver1HiiHandle, L"connect", Param2); > ShellStatus =3D SHELL_INVALID_PARAMETER; > } > diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c > b/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c > index 009ae5282b27..fd49d1f7ceb4 100644 > --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c > +++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c > @@ -160,12 +160,17 @@ ShellCommandRunDisconnect ( > Param1 =3D ShellCommandLineGetRawValue (Package, 1); > Param2 =3D ShellCommandLineGetRawValue (Package, 2); > Param3 =3D ShellCommandLineGetRawValue (Package, 3); > - ShellConvertStringToUint64 (Param1, &Intermediate1, TRUE, FALSE)= ; > - Handle1 =3D Param1 !=3D NULL ? ConvertHandleIndexToHandle > ((UINTN)Intermediate1) : NULL; > - ShellConvertStringToUint64 (Param2, &Intermediate2, TRUE, FALSE)= ; > - Handle2 =3D Param2 !=3D NULL ? ConvertHandleIndexToHandle > ((UINTN)Intermediate2) : NULL; > - ShellConvertStringToUint64 (Param3, &Intermediate3, TRUE, FALSE)= ; > - Handle3 =3D Param3 !=3D NULL ? ConvertHandleIndexToHandle > ((UINTN)Intermediate3) : NULL; > + if (!EFI_ERROR (ShellConvertStringToUint64 (Param1, &Intermediat= e1, > TRUE, FALSE))) { > + Handle1 =3D Param1 !=3D NULL ? ConvertHandleIndexToHandle > ((UINTN)Intermediate1) : NULL; > + } > + > + if (!EFI_ERROR (ShellConvertStringToUint64 (Param2, &Intermediat= e2, > TRUE, FALSE))) { > + Handle2 =3D Param2 !=3D NULL ? ConvertHandleIndexToHandle > ((UINTN)Intermediate2) : NULL; > + } > + > + if (!EFI_ERROR (ShellConvertStringToUint64 (Param3, &Intermediat= e3, > TRUE, FALSE))) { > + Handle3 =3D Param3 !=3D NULL ? ConvertHandleIndexToHandle > ((UINTN)Intermediate3) : NULL; > + } >=20 > if ((Param1 !=3D NULL) && (Handle1 =3D=3D NULL)) { > ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDL= E), > gShellDriver1HiiHandle, L"disconnect", Param1); diff --git > a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c > b/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c > index c645c9fd6882..8f70d6b6af39 100644 > --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c > +++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvDiag.c > @@ -438,25 +438,22 @@ ShellCommandRunDrvDiag ( > ControllerHandleStr =3D ShellCommandLineGetRawValue (Package, 2); > ChildHandleStr =3D ShellCommandLineGetRawValue (Package, 3); >=20 > - if (DriverHandleStr =3D=3D NULL) { > - Handle1 =3D NULL; > - } else { > - ShellConvertStringToUint64 (DriverHandleStr, &Intermediate, TRUE, > FALSE); > + if ((DriverHandleStr !=3D NULL) && ShellConvertStringToUint64 > + (DriverHandleStr, &Intermediate, TRUE, FALSE)) { > Handle1 =3D ConvertHandleIndexToHandle ((UINTN)Intermediate); > + } else { > + Handle1 =3D NULL; > } >=20 > - if (ControllerHandleStr =3D=3D NULL) { > - Handle2 =3D NULL; > - } else { > - ShellConvertStringToUint64 (ControllerHandleStr, &Intermediate, TR= UE, > FALSE); > + if ((ControllerHandleStr !=3D NULL) && ShellConvertStringToUint64 > + (ControllerHandleStr, &Intermediate, TRUE, FALSE)) { > Handle2 =3D ConvertHandleIndexToHandle ((UINTN)Intermediate); > + } else { > + Handle2 =3D NULL; > } >=20 > - if (ChildHandleStr =3D=3D NULL) { > - Handle3 =3D NULL; > - } else { > - ShellConvertStringToUint64 (ChildHandleStr, &Intermediate, TRUE, > FALSE); > + if ((ChildHandleStr !=3D NULL) && ShellConvertStringToUint64 > + (ChildHandleStr, &Intermediate, TRUE, FALSE)) { > Handle3 =3D ConvertHandleIndexToHandle ((UINTN)Intermediate); > + } else { > + Handle3 =3D NULL; > } >=20 > Status =3D DoDiagnostics ( > -- > 2.28.0.windows.1