From nobody Mon Feb 9 07:56:00 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+45054+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+45054+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1565225657; cv=none; d=zoho.com; s=zohoarc; b=H2jT4ywwAiDrSiw0heqmLyPh2hzdf8/a1/DxsY1ZlUOjQ1RjoXrF1lzIO2fIpL8bDrdj3duW+myS2DRZkfuxtyaEhQ0p5CinqKm2kMC/ZwPx4Ved8RPe74itEeBevhillGl7SBVR39SRtSAwC8ess9bXVtY7cO0LQ4nhXgSk/rc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565225657; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To:ARC-Authentication-Results; bh=UR0x4OxG/8sAx9/0mc+oF0v5BnQkZ0SMTYIBuX1TEtk=; b=gTrmH1GtEPcLpCTnzUPGiBJUAjwSNcFZ2NYq+da2+ycB7hPq3fbaPKauSvaje5IFn5lPMjM9GFbmH6DKotH6NU9dzvUEZUMSdOhPECOrA9TpjfGlrH767L0CInxnHqrjsnhespM302p6keOVo24FAFY3mIvCfQf/Fho6xwZOdQk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+45054+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 156522565748175.87588199841184; Wed, 7 Aug 2019 17:54:17 -0700 (PDT) Return-Path: X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by groups.io with SMTP; Wed, 07 Aug 2019 17:54:16 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Aug 2019 17:54:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,358,1559545200"; d="scan'208";a="193034400" X-Received: from fieedk001.ccr.corp.intel.com ([10.239.33.119]) by fmsmga001.fm.intel.com with ESMTP; 07 Aug 2019 17:54:15 -0700 From: "Gao, Zhichao" To: devel@edk2.groups.io Cc: Jaben Carsey , Ray Ni Subject: [edk2-devel] [PATCH] ShellPkg/UefiShellLevel2CommansLib: Pointer Resonse should be checked Date: Thu, 8 Aug 2019 08:54:05 +0800 Message-Id: <20190808005405.27080-1-zhichao.gao@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,zhichao.gao@intel.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1565225657; bh=CLO2HjWyGj+LHM5efQgHVAr8nPrt3wFCguJRgFCxhD0=; h=Cc:Date:From:Reply-To:Subject:To; b=ofZKDJuHbNwScirFAXe23SYmspOU2pHzvLk5aJzEJnzcKqVF0m1XIy7sPKppFQ+p6sC lKLgFr5refL+V4rJiAMV1oC/ShESJf6qtue8BCX3xfYtqxJQwHPxU+6OcCn6iVjkPDpnT b1XRCSoO6h/vUVHFQ09Ff332uhiy4HMY878= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2049 ShellPkg\Library\UefiShellLevel2CommandsLib\Cp.c line 104 and ShellPkg\Library\UefiShellLevel2CommandsLib\Mv.c line 640, the pointer variable Response may be a NULL pointer. So we should make sure that it isn't NULL before dereference it. If Response is NULL that indicates a EFI_OUT_OF_RESOURCES error, directly return SHELL_ABORTED. Cc: Jaben Carsey Cc: Ray Ni Signed-off-by: Zhichao Gao --- .../Library/UefiShellLevel2CommandsLib/Cp.c | 42 ++++++++------- .../Library/UefiShellLevel2CommandsLib/Mv.c | 52 ++++++++++--------- 2 files changed, 51 insertions(+), 43 deletions(-) diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c b/ShellPkg/Li= brary/UefiShellLevel2CommandsLib/Cp.c index 18b05b5803..632d50229a 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c @@ -2,7 +2,7 @@ Main file for cp shell level 2 function. =20 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
- Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -101,24 +101,28 @@ CopySingleFile( // possibly return based on response // if (!SilentMode) { - switch (*(SHELL_PROMPT_RESPONSE*)Response) { - case ShellPromptResponseNo: - // - // return success here so we dont stop the process - // - return (SHELL_SUCCESS); - case ShellPromptResponseCancel: - *Resp =3D Response; - // - // indicate to stop everything - // - return (SHELL_ABORTED); - case ShellPromptResponseAll: - *Resp =3D Response; - case ShellPromptResponseYes: - break; - default: - return SHELL_ABORTED; + if (Response !=3D NULL) { + switch (*(SHELL_PROMPT_RESPONSE*)Response) { + case ShellPromptResponseNo: + // + // return success here so we dont stop the process + // + return (SHELL_SUCCESS); + case ShellPromptResponseCancel: + *Resp =3D Response; + // + // indicate to stop everything + // + return (SHELL_ABORTED); + case ShellPromptResponseAll: + *Resp =3D Response; + case ShellPromptResponseYes: + break; + default: + return SHELL_ABORTED; + } + } else { + return SHELL_ABORTED; } } } diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c b/ShellPkg/Li= brary/UefiShellLevel2CommandsLib/Mv.c index 8c2852d7eb..2cfa588a8c 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c @@ -2,7 +2,7 @@ Main file for mv shell level 2 function. =20 (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.
- Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -637,29 +637,33 @@ ValidateAndMoveFiles( if (Response =3D=3D NULL) { ShellPromptForResponseHii(ShellPromptResponseTypeYesNoAllCancel, S= TRING_TOKEN (STR_GEN_DEST_EXIST_OVR), gShellLevel2HiiHandle, &Response); } - switch (*(SHELL_PROMPT_RESPONSE*)Response) { - case ShellPromptResponseNo: - FreePool(Response); - Response =3D NULL; - continue; - case ShellPromptResponseCancel: - *Resp =3D Response; - // - // indicate to stop everything - // - SHELL_FREE_NON_NULL(FullCwd); - return (SHELL_ABORTED); - case ShellPromptResponseAll: - *Resp =3D Response; - break; - case ShellPromptResponseYes: - FreePool(Response); - Response =3D NULL; - break; - default: - FreePool(Response); - SHELL_FREE_NON_NULL(FullCwd); - return SHELL_ABORTED; + if (Response !=3D NULL) { + switch (*(SHELL_PROMPT_RESPONSE*)Response) { + case ShellPromptResponseNo: + FreePool(Response); + Response =3D NULL; + continue; + case ShellPromptResponseCancel: + *Resp =3D Response; + // + // indicate to stop everything + // + SHELL_FREE_NON_NULL(FullCwd); + return (SHELL_ABORTED); + case ShellPromptResponseAll: + *Resp =3D Response; + break; + case ShellPromptResponseYes: + FreePool(Response); + Response =3D NULL; + break; + default: + FreePool(Response); + SHELL_FREE_NON_NULL(FullCwd); + return SHELL_ABORTED; + } + } else { + return SHELL_ABORTED; } Status =3D ShellDeleteFileByName(FullDestPath!=3DNULL? FullDestPath:= DestPath); } --=20 2.21.0.windows.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 (#45054): https://edk2.groups.io/g/devel/message/45054 Mute This Topic: https://groups.io/mt/32794224/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-