summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGary Lin <glin@suse.com>2018-10-11 12:02:27 +0800
committerNigel Croxon <ncroxon@redhat.com>2018-10-11 08:35:12 -0400
commitba250504b9bba87d062ff8da6a7839433f108ce4 (patch)
tree52fe0ffd0ecf9199a03fd432ea8f93f78c748670 /lib
parent6058ffcd54cffea196c5aadef4ba5b5af6114648 (diff)
downloadgnu-efi-ba250504b9bba87d062ff8da6a7839433f108ce4.tar.gz
Implement StrnCat() without StrnCpy()
StrnCpy() doesn't guarantee the dest string will be null-terminated, so we shouldn't use StrnCpy(). Signed-off-by: Gary Lin <glin@suse.com> Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/runtime/rtstr.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/runtime/rtstr.c b/lib/runtime/rtstr.c
index 65cc018..129c9f2 100644
--- a/lib/runtime/rtstr.c
+++ b/lib/runtime/rtstr.c
@@ -126,7 +126,7 @@ RtStrCat (
}
#ifndef __GNUC__
-#pragma RUNTIME_CODE(RtStrCat)
+#pragma RUNTIME_CODE(RtStrnCat)
#endif
VOID
RUNTIMEFUNCTION
@@ -136,7 +136,12 @@ RtStrnCat (
IN UINTN Len
)
{
- RtStrnCpy(Dest+StrLen(Dest), Src, Len);
+ UINTN DestSize, Size;
+
+ DestSize = StrLen(Dest);
+ Size = RtStrnLen(Src, Len);
+ RtCopyMem(Dest + DestSize, Src, Size * sizeof(CHAR16));
+ Dest[DestSize + Size] = '\0';
}
#ifndef __GNUC__