summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWenxing Hou <wenxing.hou@intel.com>2024-06-14 10:52:59 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-06-17 01:16:17 +0000
commita7dbd2ac7b359644b4961b027d711893132cdb00 (patch)
tree31ded29e6c19be4256a16bb85099c90fde539438
parentaa99d36be9ad68d8d0a99896332a9b5da10cf343 (diff)
downloadedk2-a7dbd2ac7b359644b4961b027d711893132cdb00.zip
edk2-a7dbd2ac7b359644b4961b027d711893132cdb00.tar.gz
edk2-a7dbd2ac7b359644b4961b027d711893132cdb00.tar.bz2
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 <wenxing.hou@intel.com>
-rw-r--r--CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/DummyOpensslSupport.c25
1 files 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;
}
//