From 11cffd9c3f563c68e549526a79f89a074fb516b5 Mon Sep 17 00:00:00 2001 From: Amy Chan Date: Fri, 10 Jan 2025 13:56:24 +0800 Subject: [PATCH] CryptoPkg/BaseCryptLibMbedTls : Add strncpy() support to SecCryptLib Mbedtls requires the use of strncpy(), but it is currently included in DummyOpensslSupport.c, which is not part of Mbedtls SecCryptLib. To resolve this, move strncpy() to CrtWrapper.c, as Mbedtls SecCryptLib not depend on OpensslLib Signed-off-by: Amy Chan --- .../BaseCryptLibMbedTls/SysCall/CrtWrapper.c | 20 +++++++++++++++++++ .../SysCall/DummyOpensslSupport.c | 20 ------------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/CrtWrapper.c b/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/CrtWrapper.c index f1d9b9c35c..9352ffcbda 100644 --- a/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/CrtWrapper.c +++ b/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/CrtWrapper.c @@ -47,6 +47,26 @@ strchr ( return ScanMem8 (str, AsciiStrSize (str), (char)ch); } +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; +} + /**strcmp function. **/ int strcmp ( diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/DummyOpensslSupport.c b/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/DummyOpensslSupport.c index 3b5f430378..8c34f34df6 100644 --- a/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/DummyOpensslSupport.c +++ b/CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/DummyOpensslSupport.c @@ -262,26 +262,6 @@ strcpy ( 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; -} - // // -- Character Classification Routines -- //