From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web10.14196.1669256391455474561 for ; Wed, 23 Nov 2022 18:19:51 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=lBhCm+cQ; spf=pass (domain: intel.com, ip: 192.55.52.93, 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=1669256391; x=1700792391; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=eDlk59dxuSDuUjpoah1uPBujuD9iuHr7pUugMPTQe6s=; b=lBhCm+cQNEvmLxmr5j4yauPT8KN8P+FmGbZG3ojQTFeOTRI+j+i6ckfx BLqSqD1rPwGEWb/umoTL0g4Ny0spEjrS3N0xdJloI1ysGZMBPLS4G0n0e sGdKUIOhsMh0SDFpoiNNFSiGa3unDw19RT04ScdDABfbIbVaoa2WRqT2j iMvjIC1WZkuwTdAAk2NdwCaQrqfMgXQB+LiVXaorXZib/5a9Xz15Z3c3E t2x0TOkVFXuvtbYZjRCDzYHKPYSyrodVvFzSm5GABfeYff+n7sQojJHfz 2QBg9MI5+wkZC6hoaxcirbgpHD8dwlKkZa2A+6XvNTC6OcM9ouR1IX9tj w==; X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="311835429" X-IronPort-AV: E=Sophos;i="5.96,189,1665471600"; d="scan'208";a="311835429" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2022 18:19:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="730978747" X-IronPort-AV: E=Sophos;i="5.96,189,1665471600"; d="scan'208";a="730978747" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by FMSMGA003.fm.intel.com with ESMTP; 23 Nov 2022 18:19:49 -0800 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Wed, 23 Nov 2022 18:19:49 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 23 Nov 2022 18:19:48 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Wed, 23 Nov 2022 18:19:48 -0800 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.173) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Wed, 23 Nov 2022 18:19:48 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UX09FnHF42hBcXL5AFIo7vFRUJYQOrfZ2tCbiyE3hu/qMoIL8njePgJhrF370GkMch7E1Qy4J/9gu+mFT6KuyUIYd8/eJVYKtapN0k0OoijJPaPtzArO6XOcprBq3W2DDKg2PCJCDcabStZwciO8JL5GG2q/U9OgweAxASDkD8QagnnY4hoc5AMbEo74rHmC+ieDBHdi+p68rL1fhlFH1jH/MAgX1Dv+CzTCVGmdWBFjwUjOtzfQhC3mxe2vLGmm6S/PZJwAv6cxkSCaJhTeXfIpsDuui36FyQ24g90/hP6m8ubj8IKGd50AZdnLsMgbJwGiQfA9dp5peLcIeJme7Q== 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=BHVupghKIMOA0YnLyeqFnXcU3X/Q9nkBVrhze1tHL+M=; b=Zs+I/KKD+5KtFEhpRqJfMVJ9uA/QCuwsy3RXZNks6Rg/7bhlWwl3xrrqIxg+4BJoOV3xs9uTMOzigIQCny+ba0kxDlFyMV9vtu50lgVWqg4kxrOJQp8nEtX0FLiAfnfBu28c5UzuAJE6Fib5gc0qH5o4JBk6fLnIV6exX6fQ9GbmZxzLMHGQ7mQDaVujdB8+rVcbDwZKCDlCBHYeRX58FZKKfkQi94ewTEI3U3zJs3HLYiw4b7Rp5zo8FUcaVoFOirPNNVSBBPvnawmqg0Gw57Lx7Vcv70oUrpRpaq3Ejgup5BSax0RcavB31jLWKJdIxgGx4CqtD7DvNTV1qVdggw== 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 BN0PR11MB5693.namprd11.prod.outlook.com (2603:10b6:408:164::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.18; Thu, 24 Nov 2022 02:19:46 +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.019; Thu, 24 Nov 2022 02:19:46 +0000 From: "Gao, Zhichao" To: "mikuback@linux.microsoft.com" , "devel@edk2.groups.io" CC: Erich McMillan , "Kinney, Michael D" , "Ni, Ray" Subject: Re: [PATCH v1 09/12] ShellPkg: Fix conditionally uninitialized variables Thread-Topic: [PATCH v1 09/12] ShellPkg: Fix conditionally uninitialized variables Thread-Index: AQHY9GHyk8XxOkZHA0aPh+sEdl2cQq5NamaA Date: Thu, 24 Nov 2022 02:19:46 +0000 Message-ID: References: <20221109173246.174-1-mikuback@linux.microsoft.com> <20221109173246.174-10-mikuback@linux.microsoft.com> In-Reply-To: <20221109173246.174-10-mikuback@linux.microsoft.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.6.500.17 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_|BN0PR11MB5693:EE_ x-ms-office365-filtering-correlation-id: 3955faa4-0914-41ef-aed2-08dacdc25b2d x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 8PSHoQqcpcQYx1SwTiLZYLw61cbZ00WtEeVMLAoPO0kXCNDGmVQc2j2rpiS8hsP3wU4J8CC3x8/2GH05KbEIDpHo6jt6af3vHSRFGaUxn9RCVdS8BChlz8AXMv8gxcxQ2gUeptA2QwlPCbcPq3BsvCFSUZ/KR5xhysKE1V/+FIrGtgG7B9o806ivo5jdxYqYXEHADXb1CSDNVtB8X2UV3ZMPA6umrkV1xicj5we/IuDbz971JVoYhwrutELjRVZPdUqeqXDjNVPKbB6xidhrFxtKGfMUwACJuOMHK+0A2sUbmVMFOH+kF3Dc3B38khJj4zJdath5X5kixewyYIkzZYWGtNC3OOrh4QEmCXBKESieyjpqTwP500840+RDGM3i81FWE8IcsIkbN9wlBSG4d75KsGjn3Mun1t4ipaG6s56mEugV2U0EDajFs88J0I93fRSaOnfZXE/z++WXEtBabuVtE/ddhfZX5FqX0kzAMYhdwpw3zr79S3I/WjRhKGgaAzGsiT1fqmrDYc9BYsJ0ElY+WCjFB8M/g+d2pFtak4u+mqjUMlcMB82iiSAiWg/ZmWbQYZu8AkSI7/0305qZOXzJ7suia5f/cuTpuhPXx+9ldncY4EKbXQyqiKaArtoyPiCCwto9W5B0dr1cicOmu2Sbb3RGpDP0oNNQ3Vtu4ifV0WOY4CzeTzCG905L2M/tWiml/x8rYyIYtk3/B+NlGCXJISowBBg0T0OsXOG40sA= 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)(136003)(366004)(39860400002)(346002)(376002)(451199015)(33656002)(86362001)(30864003)(55016003)(5660300002)(2906002)(9686003)(26005)(83380400001)(38070700005)(122000001)(186003)(82960400001)(38100700002)(107886003)(478600001)(71200400001)(966005)(8936002)(53546011)(41300700001)(54906003)(316002)(76116006)(19627235002)(52536014)(110136005)(4326008)(7696005)(6506007)(66476007)(64756008)(66946007)(8676002)(66556008)(66446008);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?RfZxQrEZGpBHnIoNDf9AgWYTwONRQyyP2QgZEdU4vPaVZBFqJ85zYCrpOoMX?= =?us-ascii?Q?ASoSfOZH8y5e8V3yWkF+WJolfqYbKEJuuv1FYzAvGYJvJtizgowmlQ3rsXod?= =?us-ascii?Q?gkH4hFQnQFCs2MQSWBMSeNm560b3KBzyqm2v4BapXOHYsaKXrP8Fg7eOAynF?= =?us-ascii?Q?swmCEh89tkBKrq4jti4P7PT6uEbvJhJB3lPRHBBnMfd1hagSrKDs0un86qyF?= =?us-ascii?Q?/nDKxMRFHKMtN6ONqvmmln6uux4cTLc250f3VXd3ymwFr22M5dg3NioAU8j4?= =?us-ascii?Q?oIDeYRSV+HNZ4JqeZxrd8DyOucQ1fD5Vcx+oB1mPElVe9ovKS5JEPgmV+4hY?= =?us-ascii?Q?48UQR0afmz3PpNHBKgdrflTofr6XFd5Bum66fzax5UwKnpzTrjiyl19utSte?= =?us-ascii?Q?qDytawdT+BsA1mle9cNYkVNKzIq8yeEyanS7w8Lss53voIgry78HqMuXCmdW?= =?us-ascii?Q?azmupLstPDmajA80Una34AE0p52mTn2/tju6F/Mz73Y5q7mhMMxkUElmxN/y?= =?us-ascii?Q?uAbSt5CFcRB6fglVeqmEa7xDpPmbEkvndDUyamzxgpiPngBQc55OWexDe67L?= =?us-ascii?Q?qKR/GTnXibH+4GizLy34BBc0WcpBTx5rgNljxwkQSceHC3EjCsNzYgDk8mzK?= =?us-ascii?Q?TUkv6dGEX1uHbuqZnazykzk363nn2cYOJr4YKbui61F0xwn0Mgvvfz5bfPu7?= =?us-ascii?Q?BYo98PDHluKfu3/oPFBB10iXXfOSAyXHIXkLs64dXYj96O30V8LhyWDttFw3?= =?us-ascii?Q?mp8hu3zmQ30PYkcu9xc1YJeDgjUZ+v6DvmulpTmXK8bMFOotspsB2VPGJTQq?= =?us-ascii?Q?VAEep5nhcVuc1wE9s1XxDdn5JzdtwppJSi9Es1WVUkouCSS0e5qyOiaCgHJ3?= =?us-ascii?Q?glILo1Mg+pvfJHmSwRKjU10WSK9udNEPJwB5q400iFD5ACDxGPtowmDGU2Il?= =?us-ascii?Q?hwBYLw6/VADBYT+8dI8tXQ7qVjp+oBj0sCP0TdOlqEtl2UugHrYxhC2PsAvG?= =?us-ascii?Q?3rseZBEHPinFR/ZwlKqtEUqQMhys68V2cXL77xNuQ0r18rIixodUOVHHZBs1?= =?us-ascii?Q?NUUSUbAyJDRmpUDrqQU847A603F2sy20fxasons9DOxMK9NBgqZ+v616vuWE?= =?us-ascii?Q?O3S+bvARXKkWF4N8asNbcvh6og8jGXrxVpJ8ZtChq+JdY180JNU9vPj3q2Da?= =?us-ascii?Q?4HPQRk2QoN4xST/scMEC1qMqbNtK+V6KGyz2eLwdSfGvqu+MKEucnP39HD5A?= =?us-ascii?Q?Wm+5JQssyMU6BuQO0k7Jla1Eos1GPk3/R6kzEL0iUj32c6v48/w5FFcTEHsX?= =?us-ascii?Q?Kv761RhKGimKMP3yaiK9LYf/FCTWWrawoxryrh+NmQkZwITXCbP+EChBEAxc?= =?us-ascii?Q?tWCFVpjb9lABTHf9uFkeubEv9rrSBzMipELxXD3ZAxOTnZgZxxb5vWJsN+iH?= =?us-ascii?Q?u6XYpFjJ2HPWGdShf2HS9Xg5yf7li6QpfAmAf9DfPkTD1kUb8ID4pDgW3VoE?= =?us-ascii?Q?qoWrBPSNnNGGaDyjn3RHnx25no5WxbhHsIYxKUQOG9X8LRfh5vAEuKs0VqfH?= =?us-ascii?Q?zr/JfuBiO0KZ2ZQvhWP61WIUWSDrI9c03mEPjAp8?= 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: 3955faa4-0914-41ef-aed2-08dacdc25b2d X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Nov 2022 02:19:46.3104 (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: 7oeRD61k7cqvVLsSxGHlgs0V1qK3d+yN4I1XR9zceXuiK4F8GwglhcrcyFmQAQZ4AJsr6NU5EgFZVf1drGxYuQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR11MB5693 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 See comments below: > -----Original Message----- > From: mikuback@linux.microsoft.com > Sent: Thursday, November 10, 2022 1:33 AM > To: devel@edk2.groups.io > Cc: Erich McMillan ; Kinney, Michael D > ; Michael Kubacki > ; Ni, Ray ; Gao, Zhichao > > Subject: [PATCH v1 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 | 2 +- > ShellPkg/Application/Shell/ShellProtocol.c | 4 +- > 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, 78 insertions(+), 63 deletions(-) >=20 > diff --git a/ShellPkg/Application/Shell/Shell.c > b/ShellPkg/Application/Shell/Shell.c > index df00adfdfa5b..86db2f4ebb6e 100644 > --- a/ShellPkg/Application/Shell/Shell.c > +++ b/ShellPkg/Application/Shell/Shell.c > @@ -1324,7 +1324,7 @@ DoStartupScript ( > } >=20 > Status =3D RunShellCommand (FileStringPath, &CalleeStatus); > - if (ShellInfoObject.ShellInitSettings.BitUnion.Bits.Exit =3D=3D TRUE= ) { > + if (!EFI_ERROR (Status) && > + (ShellInfoObject.ShellInitSettings.BitUnion.Bits.Exit =3D=3D TRUE)) { Incorrect here. Cannot handle the unsuccess condition. Better to assign the= success initial value to Calleestatus and keep the org logic. > ShellCommandRegisterExit (gEfiShellProtocol->BatchIsActive (), > (UINT64)CalleeStatus); > } >=20 > diff --git a/ShellPkg/Application/Shell/ShellProtocol.c > b/ShellPkg/Application/Shell/ShellProtocol.c > index 509eb60e40f4..9183da284fff 100644 > --- a/ShellPkg/Application/Shell/ShellProtocol.c > +++ b/ShellPkg/Application/Shell/ShellProtocol.c > @@ -729,8 +729,8 @@ 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); Should we cover above function as well? Others looks good to me. Thanks, Zhichao > for (HandleCount =3D 0; HandleCount < ParentDriverCount; > HandleCount++) { 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