From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.120]) by mx.groups.io with SMTP id smtpd.web10.1662.1571045943714963658 for ; Mon, 14 Oct 2019 02:39:03 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XSgcA3zV; spf=pass (domain: redhat.com, ip: 207.211.31.120, mailfrom: philmd@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571045942; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pSDJisi3wDX/25IHSUSUq1Nr7rSnw63zsX6O3DT+DdE=; b=XSgcA3zVAWGW0uKsDRFYnT0+9i6CiUuDmYQmIckvfIcjKmhk+N5lGgr7UTZcmWVJhAbqeA nnxbCAIK5PSDiPwkWEKF7PzFqUDl3XyccSadK/U6GJWOWYMJWJa/+a03b9d5Q6HhQeDWyo qyy++27VEwl8dkqNaNUbBOAM8TK/1Mw= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-311-5ioD0VqNNIqkqhKUIrIKDw-1; Mon, 14 Oct 2019 05:38:59 -0400 Received: by mail-wm1-f72.google.com with SMTP id 190so6904301wme.4 for ; Mon, 14 Oct 2019 02:38:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=xJfxGLR1UlZGN0aJVjRkQnzhFwr4IPSGuXLFSx4ByFg=; b=UJmu5rDw1e2Mnzm3VngXXe9wxCFCWU3b1u3kLJ4PjuXbqo68THdpdmqXHCjVvVoUU1 im1RWucBRQ1UmyrP687CCSD4x4f+IkteoxLXdsjDbdHz4rlU0x5aSsxynaOmzLwun6br XUw7muR7T55p/b39mhJWFtpbc3rTtMObDBtLUHlbj33IrJtuvVk7HLyo94B2t191naKL S6ymdDI51/UreP+PVQ7ZXo6IrO70veQlwZ41Q79VlzvbgMmdLo6yxHEWdotwRrbx/A+w IMSUZWtkb1WTJveRJVc+vfuPFlByuj+L7kNH2/rKoabRRxPwC4alVZLeV+mR0y6t1pp7 GSnA== X-Gm-Message-State: APjAAAXFb3OFSXi+2dR0M3S7B47zTAfpKznzwlp7uR0fLqXC095GEkvE SfkR7sAVTWoCPO9ItEMie9ODd+csmI7X8NmXdkCQvKh2kGBzhE+3hphrPeFKwgoFxuY6hSeCv6I iPoraqlQb3Q9y/g== X-Received: by 2002:a7b:c3d2:: with SMTP id t18mr15216397wmj.52.1571045937953; Mon, 14 Oct 2019 02:38:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/fYPsYRC3e0IYJZMEcUF9V2QGaIfmLQv5T2C+IC9BDSDmXBnD9jT/T00bgFcs0JXzGIyKpA== X-Received: by 2002:a7b:c3d2:: with SMTP id t18mr15216385wmj.52.1571045937727; Mon, 14 Oct 2019 02:38:57 -0700 (PDT) Return-Path: Received: from [192.168.50.32] (243.red-88-26-246.staticip.rima-tde.net. [88.26.246.243]) by smtp.gmail.com with ESMTPSA id w17sm15528851wmi.30.2019.10.14.02.38.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Oct 2019 02:38:57 -0700 (PDT) Subject: Re: [edk2-devel] [PATCH v2] ShellPkg/Shell/FileHandleWrappers.c: Add check for MemFile->Buffer To: devel@edk2.groups.io, zhichao.gao@intel.com, "Zhang, Shenglei" Cc: "Ni, Ray" References: <20191014012511.860-1-shenglei.zhang@intel.com> <3CE959C139B4C44DBEA1810E3AA6F9000B8565FD@SHSMSX101.ccr.corp.intel.com> From: =?UTF-8?B?UGhpbGlwcGUgTWF0aGlldS1EYXVkw6k=?= Message-ID: Date: Mon, 14 Oct 2019 11:38:56 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.0 MIME-Version: 1.0 In-Reply-To: <3CE959C139B4C44DBEA1810E3AA6F9000B8565FD@SHSMSX101.ccr.corp.intel.com> X-MC-Unique: 5ioD0VqNNIqkqhKUIrIKDw-1 X-Mimecast-Spam-Score: 0 Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable On 10/14/19 8:35 AM, Gao, Zhichao wrote: > Refer to CSS 5.2.2.6 Always put space before an open parenthesis. > FreePool(AsciiBuffer); should be FreePool (AsciiBuffer); > After address that, Reviewed-by: Zhichao Gao >=20 > Thanks, > Zhichao >=20 >> -----Original Message----- >> From: Zhang, Shenglei >> Sent: Monday, October 14, 2019 9:25 AM >> To: devel@edk2.groups.io >> Cc: Ni, Ray ; Gao, Zhichao >> Subject: [PATCH v2] ShellPkg/Shell/FileHandleWrappers.c: Add check for >> MemFile->Buffer >> >> 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 retu= rned. >> >> ShellPkg/Application/Shell/FileHandleWrappers.c | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/ShellPkg/Application/Shell/FileHandleWrappers.c >> b/ShellPkg/Application/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- >>> BufferSize)) { >> MemFile->Buffer =3D ReallocatePool((UINTN)(MemFile->BufferSize)= , >> (UINTN)(MemFile->BufferSize) + (*BufferSize) + >> MEM_WRITE_REALLOC_OVERHEAD, MemFile->Buffer); >> + if (MemFile->Buffer =3D=3D NULL){ Also "Always put space before an open brace (curly bracket)" >> + return EFI_OUT_OF_RESOURCES; >> + } >> MemFile->BufferSize +=3D (*BufferSize) + >> MEM_WRITE_REALLOC_OVERHEAD; >> } >> CopyMem(((UINT8*)MemFile->Buffer) + MemFile->Position, Buffer, >> *BufferSize); @@ -1661,6 +1664,10 @@ FileInterfaceMemWrite( >> AsciiSPrint(AsciiBuffer, *BufferSize, "%S", Buffer); >> if ((UINTN)(MemFile->Position + AsciiStrSize(AsciiBuffer)) > >> (UINTN)(MemFile->BufferSize)) { >> MemFile->Buffer =3D ReallocatePool((UINTN)(MemFile->BufferSize)= , >> (UINTN)(MemFile->BufferSize) + AsciiStrSize(AsciiBuffer) + >> MEM_WRITE_REALLOC_OVERHEAD, MemFile->Buffer); >> + if (MemFile->Buffer =3D=3D NULL){ >> + FreePool(AsciiBuffer); >> + return EFI_OUT_OF_RESOURCES; >> + } >> MemFile->BufferSize +=3D AsciiStrSize(AsciiBuffer) + >> MEM_WRITE_REALLOC_OVERHEAD; >> } >> CopyMem(((UINT8*)MemFile->Buffer) + MemFile->Position, AsciiBuffe= r, >> AsciiStrSize(AsciiBuffer)); >> -- >> 2.18.0.windows.1 >=20 >=20 >=20 >=20