* [PATCH] Nt32Pkg/WinNtBusDriverDxe: Fix small memory overrun
@ 2016-10-12 20:29 Thomas Palmer
2016-10-13 8:59 ` Ni, Ruiyu
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Palmer @ 2016-10-12 20:29 UTC (permalink / raw)
To: edk2-devel; +Cc: ruiyu.ni, joseph.shifflett, Thomas Palmer
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 <thomas.palmer@hpe.com>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Nt32Pkg/WinNtBusDriverDxe: Fix small memory overrun
2016-10-12 20:29 [PATCH] Nt32Pkg/WinNtBusDriverDxe: Fix small memory overrun Thomas Palmer
@ 2016-10-13 8:59 ` Ni, Ruiyu
0 siblings, 0 replies; 2+ messages in thread
From: Ni, Ruiyu @ 2016-10-13 8:59 UTC (permalink / raw)
To: Thomas Palmer, edk2-devel@lists.01.org
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
>-----Original Message-----
>From: Thomas Palmer [mailto:thomas.palmer@hpe.com]
>Sent: Thursday, October 13, 2016 4:30 AM
>To: edk2-devel@lists.01.org
>Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; joseph.shifflett@hpe.com; Thomas Palmer <thomas.palmer@hpe.com>
>Subject: [PATCH] Nt32Pkg/WinNtBusDriverDxe: Fix small memory overrun
>
>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 <thomas.palmer@hpe.com>
>---
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-10-13 8:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-12 20:29 [PATCH] Nt32Pkg/WinNtBusDriverDxe: Fix small memory overrun Thomas Palmer
2016-10-13 8:59 ` Ni, Ruiyu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox