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