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>
This commit is contained in:
parent
6058ffcd54
commit
ba250504b9
@ -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__
|
||||
|
Loading…
Reference in New Issue
Block a user