From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C39BE81CF0 for ; Thu, 3 Nov 2016 10:39:00 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 03 Nov 2016 10:38:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,587,1473145200"; d="scan'208";a="1063528813" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga001.fm.intel.com with ESMTP; 03 Nov 2016 10:38:53 -0700 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 3 Nov 2016 10:38:51 -0700 Received: from fmsmsx103.amr.corp.intel.com ([169.254.2.170]) by FMSMSX152.amr.corp.intel.com ([169.254.6.157]) with mapi id 14.03.0248.002; Thu, 3 Nov 2016 10:38:51 -0700 From: "Carsey, Jaben" To: Ard Biesheuvel CC: "edk2-devel@lists.01.org" , "Kinney, Michael D" , "Gao, Liming" Thread-Topic: [edk2] [PATCH] MdePkg/BaseMemoryLibOptDxe: check for zero length in ZeroMem () Thread-Index: AQHSNfhgSKmA/v2jzUGvqDv9knuTQKDHhldX Date: Thu, 3 Nov 2016 17:38:51 +0000 Message-ID: References: <1478194274-16524-1-git-send-email-ard.biesheuvel@linaro.org> In-Reply-To: <1478194274-16524-1-git-send-email-ard.biesheuvel@linaro.org> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: MIME-Version: 1.0 Subject: Re: [PATCH] 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: Thu, 03 Nov 2016 17:39:00 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Is it worth modifying the assert after to no longer check length being gart= er than 0? Jaben > On Nov 3, 2016, at 10:33 AM, Ard Biesheuvel w= rote: >=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 > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Ard Biesheuvel > --- > MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c | 4 ++++ > 1 file changed, 4 insertions(+) >=20 > diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c b/MdePkg= /Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c > index 2a0a038fd6c5..fbc2f5742c8c 100644 > --- a/MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c > +++ b/MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c > @@ -46,6 +46,10 @@ ZeroMem ( > IN UINTN Length > ) > { > + if (Length =3D=3D 0) { > + return Buffer; > + } > + > ASSERT (!(Buffer =3D=3D NULL && Length > 0)); > ASSERT (Length <=3D (MAX_ADDRESS - (UINTN)Buffer + 1)); > return InternalMemZeroMem (Buffer, Length); > --=20 > 2.7.4 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel