public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2] MdePkg/BaseMemoryLibOptDxe: check for zero length in ZeroMem ()
@ 2016-11-03 18:18 Ard Biesheuvel
  2016-11-03 18:31 ` Laszlo Ersek
  2016-11-04  2:05 ` Gao, Liming
  0 siblings, 2 replies; 3+ messages in thread
From: Ard Biesheuvel @ 2016-11-03 18:18 UTC (permalink / raw)
  To: edk2-devel, michael.d.kinney, liming.gao
  Cc: lersek, jaben.carsey, Ard Biesheuvel

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.

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.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

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 == NULL && Length > 0));
+  if (Length == 0) {
+    return Buffer;
+  }
+
+  ASSERT (Buffer != NULL);
   ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
   return InternalMemZeroMem (Buffer, Length);
 }
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-11-04  2:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-03 18:18 [PATCH v2] MdePkg/BaseMemoryLibOptDxe: check for zero length in ZeroMem () Ard Biesheuvel
2016-11-03 18:31 ` Laszlo Ersek
2016-11-04  2:05 ` Gao, Liming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox