From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from g4t3428.houston.hpe.com (g4t3428.houston.hpe.com [15.241.140.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4E3251A1E46 for ; Wed, 12 Oct 2016 13:29:42 -0700 (PDT) Received: from arm-build-server.us.rdlabs.hpecorp.net (arm-build-server.us.rdlabs.hpecorp.net [16.84.24.54]) by g4t3428.houston.hpe.com (Postfix) with ESMTP id 82B7C57; Wed, 12 Oct 2016 20:29:41 +0000 (UTC) From: Thomas Palmer To: edk2-devel@lists.01.org Cc: ruiyu.ni@intel.com, joseph.shifflett@hpe.com, Thomas Palmer Date: Wed, 12 Oct 2016 15:29:39 -0500 Message-Id: <1476304179-6493-1-git-send-email-thomas.palmer@hpe.com> X-Mailer: git-send-email 2.7.4 Subject: [PATCH] Nt32Pkg/WinNtBusDriverDxe: Fix small memory overrun 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: Wed, 12 Oct 2016 20:29:42 -0000 When allocating memory for a string, the CHAR16 NUL character needs two bytes of space. Use StrSize to get accurate size Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Thomas Palmer --- Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriver.c b/Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriver.c index 1516ab8..c46ee07 100644 --- a/Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriver.c +++ b/Nt32Pkg/WinNtBusDriverDxe/WinNtBusDriver.c @@ -452,8 +452,8 @@ Returns: PcdTempStr = (VOID *)LibPcdGetPtr (mPcdEnvironment[Index].Token); ASSERT (PcdTempStr != NULL); - TempStrSize = StrLen (PcdTempStr); - TempStr = AllocateMemory ((TempStrSize * sizeof (CHAR16)) + 1); + TempStrSize = StrSize (PcdTempStr); + TempStr = AllocateMemory (TempStrSize); StrCpy (TempStr, PcdTempStr); StartString = TempStr; -- 2.7.4