From a7dbd2ac7b359644b4961b027d711893132cdb00 Mon Sep 17 00:00:00 2001 From: Wenxing Hou Date: Fri, 14 Jun 2024 10:52:59 +0800 Subject: CryptoPkg: Fix strncpy for BaseCryptLibMbedTls REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2817 Because the change for strncpy, add the strncpy implementation. Signed-off-by: Wenxing Hou --- .../SysCall/DummyOpensslSupport.c | 25 +++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/DummyOpensslSupport.c b/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/DummyOpensslSupport.c index d3786f0..3b5f430 100644 --- a/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/DummyOpensslSupport.c +++ b/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/DummyOpensslSupport.c @@ -258,9 +258,28 @@ strcpy ( const char *strSource ) { - // AsciiStrCpyS (strDest, MAX_STRING_SIZE, strSource); - // return strDest; - return NULL; + AsciiStrCpyS (strDest, AsciiStrnSizeS (strSource, MAX_STRING_SIZE - 1), strSource); + return strDest; +} + +char * +strncpy ( + char *strDest, + const char *strSource, + size_t count + ) +{ + UINTN DestMax = MAX_STRING_SIZE; + + if (count < MAX_STRING_SIZE) { + DestMax = count + 1; + } else { + count = MAX_STRING_SIZE-1; + } + + AsciiStrnCpyS (strDest, DestMax, strSource, (UINTN)count); + + return strDest; } // -- cgit v1.1