From nobody Tue Nov 26 16:19:46 2024 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+48875+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+48875+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1571016314; cv=none; d=zoho.com; s=zohoarc; b=hRoj7zvHwSSpZPGzNaqZeBCj45eudBZn9zPU0KR8+1ZjuOlxaRfHQX+gp9t65QCA2WOqTCLjF63gNQB+8tCyxRSd4ueupah5xcRMghk1itQaGLxURIOvhHsvd6OGcEUJolUye3tnYQ1SF+KLBFW/yjdkzCehHpmi1r8Kh0dnsdQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571016314; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To; bh=k8NqE8BvDor00g6cJnrlqroAnIkJEi18XPr5mZT+nOI=; b=LfPZrKTCPKVAJnTHOHJffrxj+yWUDDXqFMZuACIs0A2PJHL5Ihay/H7gpzy01Wj5b6LF33+T1VUiKwVw9UNyYNPmdGdHiqFqxL5w4Sb4MksfQxALlbyM+s4WKJmUteHNFo5Gds/dCCmkRLKE23xQfA2p2o6cuAUDpYiOvuyrXJU= 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+48875+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 1571016314846916.040649859546; Sun, 13 Oct 2019 18:25:14 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id aaaaYY1788612xaaaaaaaaaa; Sun, 13 Oct 2019 18:25:14 -0700 X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web11.12991.1571016314117233536 for ; Sun, 13 Oct 2019 18:25:14 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Oct 2019 18:25:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,294,1566889200"; d="scan'208";a="199259271" X-Received: from shenglei-dev.ccr.corp.intel.com ([10.239.158.52]) by orsmga006.jf.intel.com with ESMTP; 13 Oct 2019 18:25:12 -0700 From: "Zhang, Shenglei" To: devel@edk2.groups.io Cc: Ray Ni , Zhichao Gao Subject: [edk2-devel] [PATCH v2] ShellPkg/Shell/FileHandleWrappers.c: Add check for MemFile->Buffer Date: Mon, 14 Oct 2019 09:25:11 +0800 Message-Id: <20191014012511.860-1-shenglei.zhang@intel.com> 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,shenglei.zhang@intel.com X-Gm-Message-State: aaaaaaaaaaaaaaaaaaaaaaaax1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1571016314; bh=zqyUtBbIkSrOCIoMp2dECfXk6nEMuVZHupyXyqEn3Lw=; h=Cc:Date:From:Reply-To:Subject:To; b=la1l/eLJwuIrZn8nr+aPsYALqATwl6aY+XGqmt+K+W7dLs2PtRvVlRwMUlGdDOZluM5 8iPhGJgH5d+YVesrUnzNeLXUm2usq4R59U3p6ECNUVx2UILxtxK3JHj/n0WIqrCrbroqO K2qh9aQ7R5RhXcJqTXGjkA9qtnvvecRBzvk= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add check for MemFile->Buffer. Return EFI_OUT_OF_RESOURCES if MemFile->Buffer is NULL. Cc: Ray Ni Cc: Zhichao Gao Signed-off-by: Shenglei Zhang --- v2: Add the expressiong to free AsciiBuffer before the function is returned. ShellPkg/Application/Shell/FileHandleWrappers.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ShellPkg/Application/Shell/FileHandleWrappers.c b/ShellPkg/App= lication/Shell/FileHandleWrappers.c index 587556c42495..2d7bd7bec67e 100644 --- a/ShellPkg/Application/Shell/FileHandleWrappers.c +++ b/ShellPkg/Application/Shell/FileHandleWrappers.c @@ -1644,6 +1644,9 @@ FileInterfaceMemWrite( // if ((UINTN)(MemFile->Position + (*BufferSize)) > (UINTN)(MemFile->Buff= erSize)) { MemFile->Buffer =3D ReallocatePool((UINTN)(MemFile->BufferSize), (UI= NTN)(MemFile->BufferSize) + (*BufferSize) + MEM_WRITE_REALLOC_OVERHEAD, Mem= File->Buffer); + if (MemFile->Buffer =3D=3D NULL){ + return EFI_OUT_OF_RESOURCES; + } MemFile->BufferSize +=3D (*BufferSize) + MEM_WRITE_REALLOC_OVERHEAD; } CopyMem(((UINT8*)MemFile->Buffer) + MemFile->Position, Buffer, *Buffer= Size); @@ -1661,6 +1664,10 @@ FileInterfaceMemWrite( AsciiSPrint(AsciiBuffer, *BufferSize, "%S", Buffer); if ((UINTN)(MemFile->Position + AsciiStrSize(AsciiBuffer)) > (UINTN)(M= emFile->BufferSize)) { MemFile->Buffer =3D ReallocatePool((UINTN)(MemFile->BufferSize), (UI= NTN)(MemFile->BufferSize) + AsciiStrSize(AsciiBuffer) + MEM_WRITE_REALLOC_O= VERHEAD, MemFile->Buffer); + if (MemFile->Buffer =3D=3D NULL){ + FreePool(AsciiBuffer); + return EFI_OUT_OF_RESOURCES; + } MemFile->BufferSize +=3D AsciiStrSize(AsciiBuffer) + MEM_WRITE_REALL= OC_OVERHEAD; } CopyMem(((UINT8*)MemFile->Buffer) + MemFile->Position, AsciiBuffer, As= ciiStrSize(AsciiBuffer)); --=20 2.18.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 (#48875): https://edk2.groups.io/g/devel/message/48875 Mute This Topic: https://groups.io/mt/34528724/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-