From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4E39C81D65 for ; Thu, 3 Nov 2016 19:06:11 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP; 03 Nov 2016 19:06:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,589,1473145200"; d="scan'208";a="1080378748" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga002.fm.intel.com with ESMTP; 03 Nov 2016 19:05:59 -0700 Received: from fmsmsx120.amr.corp.intel.com (10.18.124.208) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 3 Nov 2016 19:05:59 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx120.amr.corp.intel.com (10.18.124.208) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 3 Nov 2016 19:05:58 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.206]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.139]) with mapi id 14.03.0248.002; Fri, 4 Nov 2016 10:05:56 +0800 From: "Gao, Liming" To: Ard Biesheuvel , "edk2-devel@lists.01.org" , "Kinney, Michael D" CC: "lersek@redhat.com" , "Carsey, Jaben" Thread-Topic: [PATCH v2] MdePkg/BaseMemoryLibOptDxe: check for zero length in ZeroMem () Thread-Index: AQHSNf6rrLk9MAR9FE2s9s4NE1WxXKDIE9ZQ Date: Fri, 4 Nov 2016 02:05:54 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14B49E90E@shsmsx102.ccr.corp.intel.com> References: <1478197093-17209-1-git-send-email-ard.biesheuvel@linaro.org> In-Reply-To: <1478197093-17209-1-git-send-email-ard.biesheuvel@linaro.org> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2] MdePkg/BaseMemoryLibOptDxe: check for zero length in ZeroMem () X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2016 02:06:11 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Ard: Could you help apply this changes for other BaseMemoryLib instances in Md= ePkg?=20 Thanks Liming > -----Original Message----- > From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] > Sent: Friday, November 04, 2016 2:18 AM > To: edk2-devel@lists.01.org; Kinney, Michael D > ; Gao, Liming > Cc: lersek@redhat.com; Carsey, Jaben ; Ard > Biesheuvel > Subject: [PATCH v2] MdePkg/BaseMemoryLibOptDxe: check for zero length > in ZeroMem () >=20 > Unlike other string functions in this library, ZeroMem () does not > return early when the length of the input buffer is 0. So add the > same to ZeroMem () as well. >=20 > This fixes an issue with the ARM implementation, whose > InternalMemZeroMem > code does not expect a length of 0, and always writes at least a single > byte. >=20 > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Ard Biesheuvel > --- > MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) >=20 > diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c > b/MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c > index 2a0a038fd6c5..9dd0b45e188e 100644 > --- a/MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c > +++ b/MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c > @@ -46,7 +46,11 @@ ZeroMem ( > IN UINTN Length > ) > { > - ASSERT (!(Buffer =3D=3D NULL && Length > 0)); > + if (Length =3D=3D 0) { > + return Buffer; > + } > + > + ASSERT (Buffer !=3D NULL); > ASSERT (Length <=3D (MAX_ADDRESS - (UINTN)Buffer + 1)); > return InternalMemZeroMem (Buffer, Length); > } > -- > 2.7.4