4c0d37
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
4c0d37
From: Gary Lin <glin@suse.com>
4c0d37
Date: Tue, 9 Oct 2018 18:35:21 +0800
4c0d37
Subject: [PATCH] Set '\0' properly in StrnCpy()
4c0d37
4c0d37
The arguments to SetMem() were wrong. Besides, SetMem() should start at
4c0d37
"Dest + Size" since "Size" will be smaller than "Len" if they are not
4c0d37
equal.
4c0d37
4c0d37
Signed-off-by: Gary Lin <glin@suse.com>
4c0d37
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
4c0d37
---
4c0d37
 lib/runtime/rtstr.c | 2 +-
4c0d37
 1 file changed, 1 insertion(+), 1 deletion(-)
4c0d37
4c0d37
diff --git a/lib/runtime/rtstr.c b/lib/runtime/rtstr.c
4c0d37
index 129c9f21ad5..73965cae192 100644
4c0d37
--- a/lib/runtime/rtstr.c
4c0d37
+++ b/lib/runtime/rtstr.c
4c0d37
@@ -71,7 +71,7 @@ RtStrnCpy (
4c0d37
 {
4c0d37
     UINTN Size = RtStrnLen(Src, Len);
4c0d37
     if (Size != Len)
4c0d37
-    RtSetMem(Dest + Len, '\0', (UINT8)((Len - Size) * sizeof(CHAR16)));
4c0d37
+        RtSetMem(Dest + Size, (Len - Size) * sizeof(CHAR16), '\0');
4c0d37
     RtCopyMem(Dest, Src, Size * sizeof(CHAR16));
4c0d37
 }
4c0d37