From nobody Thu Apr 25 00:01:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+96560+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+96560+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1669131431640736.9027297697754; Tue, 22 Nov 2022 07:37:11 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id bcOrYY1788612xCBXVj01Lzm; Tue, 22 Nov 2022 07:37:10 -0800 X-Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.49]) by mx.groups.io with SMTP id smtpd.web11.17696.1669120449178839674 for ; Tue, 22 Nov 2022 04:34:09 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RiYBwbxNx1e7JDf4/3e2OcpXy675PCmqbs8wUlfZK2VjQloP4+o4SUbKiXbIw7i7Qj5Lne8+ziqAsQi4eYXw4fNXmEE8rdmDRaQICE6JFW8dHuuqvXw9cZt4/DsZU/TXdtHJf39Hstr5HNcvaiGl0KqarhleeRVm8GrLVlbbUUJK+zGZ248e/HSjj0r0QlicBlNhrJhO8L18zULxGmrTcfz4bDT/ztSWdDQHhNRRonWzTcNET1pWpQrH9N4a1sisxTrRiIXeG96MlAVbgtcV6dQRT8yRg45llDTYjkRVfPmdVUJjMcip08VN4/Mlm3+J2qfCXK1VSsP6fEuXVK4HmQ== 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=ZSs+Xt5BbQHP5NSznoH/o2sMKZgQ/PlrVbL0ZlK/Kas=; b=mTMbDiwOTeeNEdQRHBPBEhfD7BjMedYd6HkoRTIoXH6DnoGJbjbsVbwBF07+DfhF9tO+5bsXp+EGguMypkz55YveNwjK/oZS4ZLeUP/yerar5Qx1AWdRYMCNMqNjMpyIVQuvFXG4Qf9owwTRfDj2CwLYNPFYJ8wYfoMpacnw2U62/I9nvdsQHxfgMDw91tBN3gX2zYwuT7IZSgy30PTJ55KLG5KT/y8D/3nbsOZ4JTJDj/vfHzlz5r+JNZ3HpIjiUUF1zWVup0kodXlkIvMd3UCflSq3NvZ0gA09W6eyij/6kjeDTiUd/OiR4Qf8qIxlOPCEIShi370/qGOGbkYfRg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ami.com; dmarc=pass action=none header.from=ami.com; dkim=pass header.d=ami.com; arc=none X-Received: from PH7PR10MB5831.namprd10.prod.outlook.com (2603:10b6:510:132::19) by DS7PR10MB4958.namprd10.prod.outlook.com (2603:10b6:5:3a6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.15; Tue, 22 Nov 2022 12:34:05 +0000 X-Received: from PH7PR10MB5831.namprd10.prod.outlook.com ([fe80::16c9:3d68:c72c:364c]) by PH7PR10MB5831.namprd10.prod.outlook.com ([fe80::16c9:3d68:c72c:364c%9]) with mapi id 15.20.5834.015; Tue, 22 Nov 2022 12:34:04 +0000 From: "Kalaivani P via groups.io" To: "devel@edk2.groups.io" , Kalaivani P CC: Sundaresan S , Vasudevan S , Arun K Subject: [edk2-devel] [PATCH] Multiple Coverity issues were found from EDK2 ShellPkg Thread-Topic: [PATCH] Multiple Coverity issues were found from EDK2 ShellPkg Thread-Index: AQHY/m61/HdgqtnrbUiHlQismoZuHg== Date: Tue, 22 Nov 2022 12:34:04 +0000 Message-ID: <20221122122806.1732-1-kalaivanip@ami.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PH7PR10MB5831:EE_|DS7PR10MB4958:EE_ x-ms-office365-filtering-correlation-id: 77fe6ab4-f027-4598-d796-08dacc85d787 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: BGa+BqrWaoD3ETFjxYjAOWPuWLuwCf/nQ7qzL986fST5IvK4lc1sjTgLyuoSDlReZ3u1b41xyfpPE78Whl3DzQnicrIB3uZMjh6RpTwfkE8cSXDLwGsH81nHMr+7aWAENjjAcnD3y1Y0u925F5KOS1VysptvjpnITYEqszFuXWV6L9oCjSaxyURrv8ziUY+ThHN+pd5ka5v2glJR5+5TEGoLK/pBRDpZGotFXcUHE6rRcPoQdWDhDUPN/n+UGe9+gVGK9Af4oorUr0enFYvII+oHOh50Zwz+8A4JZ7K4IR+rzgRe7Jywron5Y8nli+PGtY1NKZadPPleOl0iv8h4MG7mg9Vx6GpD3NlTgjVVfRkwvDYipOgxx+S91DgiE5a86CawWDqKfmlCYBmjPd7etYKFbZh2F6obcjl1jjstqxQfxfmb/v6excGfAUcvCOrCpvKA7t+kGJA2rC++AnviNshKgS19XHaP12FtddXzzBC2EilVK2TbH6XWWP2wRJOgHm7XSEvEO+/WXHfaepqpOb+vve7HwApg5smrFA8N1JD39RZr91IMDW6QqqOYmlMy+gKSyFJ/h97w/U4tqst+jxG6Ymey8wb+LyWDCk/KM91/B7YYNIeOFsYjCbCazvMKjCkJfATtbptfLNgVf5zp1E0f+vWBfmBDoRbE2m078pt8Pqx68cIPu/qTvak8E1LasIc7Y/kF3RRDr85H5HBBng== x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?3RuuRlfRIs7j7WnQsIP9wpAB65Ikbsv5ishUif1/C2p+EHsdiMaOsSmwnx?= =?iso-8859-1?Q?Ea6E3q4CSUH6yccG2pdYQtTku5GulQS5E1+hndhG2pSYujHlL8Nnbfl39v?= =?iso-8859-1?Q?fyg5x6e6eR8agKQwj8tipYeGo+Psy/8Vxc9ggXTDEg5VibgjpW+OVtXQzC?= =?iso-8859-1?Q?kZhPV6/Ahtdsav7+/PmMefjizvCWnp7GuQQMEMv3kFoSaH0lKYsrQCQSti?= =?iso-8859-1?Q?VnRcdZ2r4yBuNT1hBcCJD5OxI1xF1fHzgfhlZzYI/fCqdxyivn/Xi2L86J?= =?iso-8859-1?Q?kxts7bxKcBKiwnix65DitJo/KlQk8Ar03MGvyR8PmFZMXqTFfzMgEm1AKa?= =?iso-8859-1?Q?C/12Nj8eVFMtKHzkE7IzxzEpjja3UjYO3l3SIeuZsLGKaaaXjjGnP1XPsa?= =?iso-8859-1?Q?ZptVvhy35lc9iYbD7VZApBTwD74sxqR9lO3eFqq1lpcZWVCKzG/nTjdeOP?= =?iso-8859-1?Q?zA6u5tzKERThVURfmPHtNZcJenPgUOW/asEVKAkl5ZtHxHGHvkjpdDAcUf?= =?iso-8859-1?Q?otgWDGM90V++LSJTxWSIg77a1JQ6DmZC3NU/IvrlPzaqQIlL88mUa70uK+?= =?iso-8859-1?Q?kugWUL7QMscZYBn1LEpauJHdxQgrCe93WAM/bWs1QvPn1mzKgVeU76Gz65?= =?iso-8859-1?Q?5QCwJ77D1RTtTFVuPoNO7DXXUCkCh/A1SI56vsKw5OgisYjO/TGDt0UX7E?= =?iso-8859-1?Q?X2dAvmq2JOCOtZFqTFLeQhpaGY1vte0TORODwwxYiiue6A1IPGPENBBSwt?= =?iso-8859-1?Q?q5f7h/MHjNReeU2Gc+1+G4Zraik3NLd2LIQBynd+MBBCjOdiHZ6aWl21Sq?= =?iso-8859-1?Q?AR8wy474aSwiCKIfAqK166BkblcVGBbgQdYN9wwK+S7MX1iNaXtcU7kk7r?= =?iso-8859-1?Q?EUlyClNwNQyah9+5eEDNfko9Mph5S9cJnGOYVKrwMspg2oSk6UWyoW/2b0?= =?iso-8859-1?Q?PxY5gxzT4KPUcHMKoqWKtB7rvQ6BDM1zKROU51RkZd4qfyY0QZ8N9y4atm?= =?iso-8859-1?Q?NPglDtC+Qr6EeL7nbHvubQqnSsKqtaq8IKdVo6ta8EfwjMqanh5GY3H9TI?= =?iso-8859-1?Q?1UV54m7BE8DVPo6wf3pQ/YVSYFFI8K6TJpE6VSjIGBKN645cFvkM8Nwdw7?= =?iso-8859-1?Q?2Dt8eU9X+fYNUwToymStfU0N/bWH6e27fRZ1dEzylaxcaT5wmR67VwKmUh?= =?iso-8859-1?Q?5Zo3XsFkIgHZiT/56kxluYc/FeLTo6KfjXvSMZSxjB4Uir2cw10k7XfSeK?= =?iso-8859-1?Q?h01wtxvZRVcb9FVDWi1No5g/owFGvj2KGWU0nnQ6nLvbJuExPlSG0o3Op9?= =?iso-8859-1?Q?niFiwL9ERW5Ko4Sk4fbgFLTAUcYgb1xdpos2g53XfxX3MKMDv4cSG5oHo1?= =?iso-8859-1?Q?V04wMtk1f3zqV3X2De066rJjNiglAtU/ZTts2LoNvK7N3VVHdbd2Zf827I?= =?iso-8859-1?Q?I2x2ncEOVcnUPa7/QiNooh+NeiFl5GvNp6uB5LIAmNQZev57GUqjUv5kcr?= =?iso-8859-1?Q?Hz6PT/N5e1hIRp+6RRitpEWXz2KOCQpL0qJkkJ3JU8q/YhLSbiH9ZtRud4?= =?iso-8859-1?Q?nz4hsq7mP5mBCXA0y1jf7mZrMOjwwimpkF/bh45yNES7JPHWhpqZMPVVzT?= =?iso-8859-1?Q?Xw0trVoQt0lgiFnZB1Cp/5X/8Z5gqajeWx?= MIME-Version: 1.0 X-OriginatorOrg: ami.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH7PR10MB5831.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 77fe6ab4-f027-4598-d796-08dacc85d787 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Nov 2022 12:34:04.4910 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 27e97857-e15f-486c-b58e-86c2b3040f93 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: cwpsSk2WtwCIPGGlax7pqKev0DRTxbCz2ItkVmasBZPAnMF15Kq1PZvXiF4jok97DzmABudm8xALnVBmLBmF9A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4958 Precedence: Bulk List-Unsubscribe: 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,kalaivanip@ami.com X-Gm-Message-State: 7MScxIwxTiVE33Rpel5Zjo7Ox1787277AA= Content-Language: en-US Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1669131430; bh=Cg1iI7skdEF9q8cHTPk3KhX2N3WGTb1aT1qiJCwoHKM=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=I67P5wuiekrA+bwFaE9ROy5ZpO+vRkxqJe17k0hLwGkTX6G4sjV+gNGjEsKkUlYNIi3 aNdCmW5Q0H3Syc1w4YQNGADNgOgAS9NLYqx8IP8ZiGWo5AGv/4rQzKn3V7OuJn8Zugf0W SpXkk/nQgNcOz8nWrIqO088JM/v1YLoa2IA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1669131432193100018 Content-Type: text/plain; charset="utf-8" Attached is the report for Coverity issues identified in ShellPkg based on edk2-stable202205. Cc: Vasudevan Sambandan Cc: Sundaresan Selvaraj Cc: Arun k Signed-off-by: kalaivani P --- ShellPkg/Application/Shell/ShellManParser.c | 14 ++++++++- ShellPkg/Application/Shell/ShellProtocol.c | 9 +++++- .../Library/UefiShellDebug1CommandsLib/Dblk.c | 12 +++++-- .../HexEdit/BufferImage.c | 18 +++++++++-- .../HexEdit/FileImage.c | 14 ++++++++- .../UefiShellDriver1CommandsLib/DrvCfg.c | 9 +++++- .../Library/UefiShellLevel1CommandsLib/For.c | 12 +++++++ .../Library/UefiShellLevel1CommandsLib/If.c | 12 +++++++ .../Library/UefiShellLevel2CommandsLib/Vol.c | 13 +++++++- .../Library/UefiShellLevel3CommandsLib/Help.c | 13 +++++++- ShellPkg/Library/UefiShellLib/UefiShellLib.c | 31 ++++++++++++++++--- 11 files changed, 141 insertions(+), 16 deletions(-) diff --git a/ShellPkg/Application/Shell/ShellManParser.c b/ShellPkg/Applica= tion/Shell/ShellManParser.c index 5c823cd7f5..7310601231 100644 --- a/ShellPkg/Application/Shell/ShellManParser.c +++ b/ShellPkg/Application/Shell/ShellManParser.c @@ -1,3 +1,10 @@ +//*********************************************************************** +//* * +//* Copyright (c) 1985-2022, American Megatrends International LLC. * +//* * +//* All rights reserved. Subject to AMI licensing agreement. * +//* * +//*********************************************************************** /** @file Provides interface to shell MAN file parser. @@ -601,7 +608,12 @@ ProcessManFile ( if (TempString !=3D NULL) { FileHandle =3D ConvertEfiFileProtocolToShellHandle (CreateFileInterfac= eMem (TRUE), NULL); HelpSize =3D StrLen (TempString) * sizeof (CHAR16); - ShellWriteFile (FileHandle, &HelpSize, TempString); + //*** AMI PORTING BEGIN ***// + Status =3D ShellWriteFile (FileHandle, &HelpSize, TempString); + if (EFI_ERROR (Status)) { + return Status; + } + //*** AMI PORTING END ***// ShellSetFilePosition (FileHandle, 0); HelpSize =3D 0; BriefSize =3D 0; diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Applicat= ion/Shell/ShellProtocol.c index 509eb60e40..c106bcd49d 100644 --- a/ShellPkg/Application/Shell/ShellProtocol.c +++ b/ShellPkg/Application/Shell/ShellProtocol.c @@ -1,3 +1,10 @@ +//*********************************************************************** +//* * +//* Copyright (c) 1985-2022, American Megatrends International LLC. * +//* * +//* All rights reserved. Subject to AMI licensing agreement. * +//* * +//*********************************************************************** /** @file Member functions of EFI_SHELL_PROTOCOL and functions for creation, manipulation, and initialization of EFI_SHELL_PROTOCOL. @@ -2518,7 +2525,7 @@ ShellSearchHandle ( EfiShellClose (ShellInfoNode->Handle); ShellInfoNode->Handle =3D NULL; } - } else if (!EFI_ERROR (Status)) { + } else if (!EFI_ERROR (Status) && (ShellInfoNode->FullName =3D= =3D NULL)) { // AMI OVERRIDE // // should be a file // diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c b/ShellPkg/= Library/UefiShellDebug1CommandsLib/Dblk.c index 97a4b57a93..d18126213f 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c @@ -1,3 +1,10 @@ +//*********************************************************************** +//* * +//* Copyright (c) 1985-2022, American Megatrends International LLC. * +//* * +//* All rights reserved. Subject to AMI licensing agreement. * +//* * +//*********************************************************************** /** @file Main file for Dblk shell Debug1 function. @@ -45,8 +52,7 @@ DisplayTheBlocks ( if (EFI_ERROR (Status)) { return (SHELL_NOT_FOUND); } - - BufferSize =3D BlockIo->Media->BlockSize * BlockCount; + BufferSize =3D BlockIo->Media->BlockSize * (UINTN)BlockCount; // AMI OVE= RRIDE if (BlockIo->Media->IoAlign =3D=3D 0) { BlockIo->Media->IoAlign =3D 1; } @@ -55,7 +61,7 @@ DisplayTheBlocks ( OriginalBuffer =3D AllocateZeroPool (BufferSize + BlockIo->Media->IoAl= ign); Buffer =3D ALIGN_POINTER (OriginalBuffer, BlockIo->Media->IoAl= ign); } else { - ShellPrintEx (-1, -1, L" BlockSize: 0x%08x, BlockCount: 0x%08x\r\n", = BlockIo->Media->BlockSize, BlockCount); + ShellPrintEx (-1, -1, L" BlockSize: 0x%08x, BlockCount: 0x%08x\r\n", = BlockIo->Media->BlockSize,(UINTN)BlockCount); // AMI OVERRIDE OriginalBuffer =3D NULL; Buffer =3D NULL; } diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImag= e.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.c index be77e31a40..7e55be3dae 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.c @@ -1,3 +1,10 @@ +//*********************************************************************** +//* * +//* Copyright (c) 1985-2022, American Megatrends International LLC. * +//* * +//* All rights reserved. Subject to AMI licensing agreement. * +//* * +//*********************************************************************** /** @file Defines HBufferImage - the view of the file that is visible at any point, as well as the event handlers for editing the file @@ -2036,7 +2043,8 @@ HBufferImageAddCharacterToBuffer ( UINTN OldPos; UINTN NewPos; - + EFI_STATUS Status; // AMI OVERRIDE + Size =3D HBufferImageGetTotalSize (); // @@ -2083,10 +2091,14 @@ HBufferImageAddCharacterToBuffer ( Size +=3D Count; HBufferImageFreeLines (); - - HBufferImageBufferToList (Buffer, Size); + Status =3D HBufferImageBufferToList (Buffer, Size); //*** AMI PORTING *= **// FreePool (Buffer); + //*** AMI PORTING BEGIN ***// + if (EFI_ERROR (Status)) { + return Status; + } + //*** AMI PORTING END ***// Link =3D HMainEditor.BufferImage->ListHead->ForwardLink; for (Index =3D 0; Index < (INTN)NewPos / 0x10; Index++) { diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.= c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c index d8818dd958..b4e4a143c0 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/FileImage.c @@ -1,3 +1,10 @@ +//*********************************************************************** +//* * +//* Copyright (c) 1985-2022, American Megatrends International LLC. * +//* * +//* All rights reserved. Subject to AMI licensing agreement. * +//* * +//*********************************************************************** /** @file Functions to deal with file buffer. @@ -245,6 +252,7 @@ HFileImageRead ( @retval EFI_SUCCESS The operation was successful. @retval EFI_OUT_OF_RESOURCES A memory allocation failed. @retval EFI_LOAD_ERROR A load error occurred. + @retval EFI_INVALID_PARAMETER FileName input parameter is NULL. **/ EFI_STATUS HFileImageSave ( @@ -264,7 +272,11 @@ HFileImageSave ( BufferTypeBackup =3D HBufferImage.BufferType; HBufferImage.BufferType =3D FileTypeFileBuffer; - + //*** AMI PORTING BEGIN ***// + if (FileName =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + //*** AMI PORTING END ***// // // if is the old file // diff --git a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c b/ShellP= kg/Library/UefiShellDriver1CommandsLib/DrvCfg.c index 9bbbb1444d..6bebf565f5 100644 --- a/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c +++ b/ShellPkg/Library/UefiShellDriver1CommandsLib/DrvCfg.c @@ -1,3 +1,10 @@ +//*********************************************************************** +//* * +//* Copyright (c) 1985-2022, American Megatrends International LLC. * +//* * +//* All rights reserved. Subject to AMI licensing agreement. * +//* * +//*********************************************************************** /** @file Main file for DrvCfg shell Driver1 function. @@ -355,7 +362,7 @@ ConfigFromFile ( } MainBuffer =3D AllocateZeroPool ((UINTN)MainBufferSize); - if (EFI_ERROR (Status)) { + if (MainBuffer =3D=3D NULL) { // AMI OVERRIDE ShellPrintHiiEx ( -1, -1, diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c b/ShellPkg/L= ibrary/UefiShellLevel1CommandsLib/For.c index 8a6a940f28..f34acde353 100644 --- a/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c +++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/For.c @@ -1,3 +1,10 @@ +//*********************************************************************** +//* * +//* Copyright (c) 1985-2022, American Megatrends International LLC. * +//* * +//* All rights reserved. Subject to AMI licensing agreement. * +//* * +//*********************************************************************** /** @file Main file for endfor and for shell level 1 functions. @@ -335,6 +342,11 @@ ShellCommandRunFor ( CurrentScriptFile =3D ShellCommandGetCurrentScriptFile (); ASSERT (CurrentScriptFile !=3D NULL); + //*** AMI PORTING BEGIN ***// + if (CurrentScriptFile =3D=3D NULL) { + return (SHELL_DEVICE_ERROR); + } + //*** AMI PORTING END ***// if ((CurrentScriptFile->CurrentCommand !=3D NULL) && (CurrentScriptFile-= >CurrentCommand->Data =3D=3D NULL)) { FirstPass =3D TRUE; diff --git a/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c b/ShellPkg/Li= brary/UefiShellLevel1CommandsLib/If.c index b4a6966edb..2cbafef0d1 100644 --- a/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c +++ b/ShellPkg/Library/UefiShellLevel1CommandsLib/If.c @@ -1,3 +1,10 @@ +//*********************************************************************** +//* * +//* Copyright (c) 1985-2022, American Megatrends International LLC. * +//* * +//* All rights reserved. Subject to AMI licensing agreement. * +//* * +//*********************************************************************** /** @file Main file for If and else shell level 1 function. @@ -100,6 +107,11 @@ IsValidProfile ( ProfilesString =3D ShellGetEnvironmentVariable (L"profiles"); ASSERT (ProfilesString !=3D NULL); + //*** AMI PORTING BEGIN ***// + if (ProfilesString =3D=3D NULL) { + return FALSE; + } + //*** AMI PORTING END ***// TempLocation =3D StrStr (ProfilesString, String); if ((TempLocation !=3D NULL) && (*(TempLocation-1) =3D=3D L';') && (*(Te= mpLocation+StrLen (String)) =3D=3D L';')) { return (TRUE); diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c b/ShellPkg/L= ibrary/UefiShellLevel2CommandsLib/Vol.c index 8f7310c074..61470249f7 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Vol.c @@ -1,3 +1,10 @@ +//*********************************************************************** +//* * +//* Copyright (c) 1985-2022, American Megatrends International LLC. * +//* * +//* All rights reserved. Subject to AMI licensing agreement. * +//* * +//*********************************************************************** /** @file Main file for vol shell level 2 function. @@ -97,7 +104,11 @@ HandleVol ( } ASSERT (SysInfo !=3D NULL); - + //*** AMI PORTING BEGIN ***// + if (SysInfo =3D=3D NULL) { + return (SHELL_OUT_OF_RESOURCES);; + } + //*** AMI PORTING END ***// if (Delete) { *((CHAR16 *)SysInfo->VolumeLabel) =3D CHAR_NULL; SysInfo->Size =3D SIZE_OF_EFI_FILE_SYSTEM_INFO + S= trSize (SysInfo->VolumeLabel); diff --git a/ShellPkg/Library/UefiShellLevel3CommandsLib/Help.c b/ShellPkg/= Library/UefiShellLevel3CommandsLib/Help.c index 7f146bb9fb..21e62c9ee8 100644 --- a/ShellPkg/Library/UefiShellLevel3CommandsLib/Help.c +++ b/ShellPkg/Library/UefiShellLevel3CommandsLib/Help.c @@ -1,3 +1,10 @@ +//*********************************************************************** +//* * +//* Copyright (c) 1985-2022, American Megatrends International LLC. * +//* * +//* All rights reserved. Subject to AMI licensing agreement. * +//* * +//*********************************************************************** /** @file Main file for Help shell level 3 function. @@ -117,7 +124,11 @@ CopyListOfCommandNames ( ) { CONST COMMAND_LIST *Node; - + //*** AMI PORTING BEGIN ***// + if (SourceList =3D=3D NULL) { + return SHELL_INVALID_PARAMETER;; + } + //*** AMI PORTING END ***// for ( Node =3D (COMMAND_LIST *)GetFirstNode (&SourceList->Link) ; SourceList !=3D NULL && !IsListEmpty (&SourceList->Link) && !IsN= ull (&SourceList->Link, &Node->Link) ; Node =3D (COMMAND_LIST *)GetNextNode (&SourceList->Link, &Node->= Link) diff --git a/ShellPkg/Library/UefiShellLib/UefiShellLib.c b/ShellPkg/Librar= y/UefiShellLib/UefiShellLib.c index a72767bd86..1746bbcb2d 100644 --- a/ShellPkg/Library/UefiShellLib/UefiShellLib.c +++ b/ShellPkg/Library/UefiShellLib/UefiShellLib.c @@ -1,3 +1,11 @@ +//*********************************************************************** +//* * +//* Copyright (c) 1985-2022, American Megatrends International LLC. * +//* * +//* All rights reserved. Subject to AMI licensing agreement. * +//* * +//*********************************************************************** + /** @file Provides interface to shell functionality for shell commands and applica= tions. @@ -1761,7 +1769,11 @@ ShellCloseFileMetaArg ( // ASSERT that ListHead is not NULL // ASSERT (ListHead !=3D NULL); - + //*** AMI PORTING BEGIN ***// + if (ListHead =3D=3D NULL) { + return (SHELL_INVALID_PARAMETER); + } + //*** AMI PORTING END ***// // // Check for UEFI Shell 2.0 protocols // @@ -2221,6 +2233,10 @@ InternalCommandLineParse ( if (CurrentItemPackage->Name =3D=3D NULL) { ShellCommandLineFreeVarList (*CheckPackage); *CheckPackage =3D NULL; + //*** AMI PORTING BEGIN ***// + // Fixing memory leak here + SHELL_FREE_NON_NULL (CurrentItemPackage); + //*** AMI PORTING END ***// return (EFI_OUT_OF_RESOURCES); } @@ -2323,6 +2339,10 @@ InternalCommandLineParse ( if (CurrentItemPackage->Value =3D=3D NULL) { ShellCommandLineFreeVarList (*CheckPackage); *CheckPackage =3D NULL; + //*** AMI PORTING BEGIN ***// + // Fixing memory leak here + SHELL_FREE_NON_NULL (CurrentItemPackage); + //*** AMI PORTING END ***// return (EFI_OUT_OF_RESOURCES); } @@ -4377,9 +4397,12 @@ ShellFileHandleReadLine ( return (EFI_INVALID_PARAMETER); } - if (Buffer =3D=3D NULL) { - ASSERT (*Size =3D=3D 0); - } else { + //*** AMI PORTING BEGIN ***// + if ((Buffer =3D=3D NULL) || (*Size =3D=3D 0)) { + return EFI_INVALID_PARAMETER; + } + //*** AMI PORTING END ***// + else { *Buffer =3D CHAR_NULL; } -- 2.36.0.windows.1 -The information contained in this message may be confidential and propriet= ary to American Megatrends (AMI). This communication is intended to be read= only by the individual or entity to whom it is addressed or by their desig= nee. If the reader of this message is not the intended recipient, you are o= n notice that any distribution of this message, in any form, is strictly pr= ohibited. Please promptly notify the sender by reply e-mail or by telephone= at 770-246-8600, and then delete or destroy all copies of the transmission. -=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 (#96560): https://edk2.groups.io/g/devel/message/96560 Mute This Topic: https://groups.io/mt/95197753/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-