diff options
author | Gary Lin <glin@suse.com> | 2018-10-11 12:02:27 +0800 |
---|---|---|
committer | Nigel Croxon <ncroxon@redhat.com> | 2018-10-11 08:35:12 -0400 |
commit | ba250504b9bba87d062ff8da6a7839433f108ce4 (patch) | |
tree | 52fe0ffd0ecf9199a03fd432ea8f93f78c748670 /lib | |
parent | 6058ffcd54cffea196c5aadef4ba5b5af6114648 (diff) | |
download | gnu-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.c | 9 |
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__ |