Skip to content

Commit 11cffd9

Browse files
AmyChan-Intelmergify[bot]
authored andcommitted
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 <[email protected]>
1 parent c0533b7 commit 11cffd9

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/CrtWrapper.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,26 @@ strchr (
4747
return ScanMem8 (str, AsciiStrSize (str), (char)ch);
4848
}
4949

50+
char *
51+
strncpy (
52+
char *strDest,
53+
const char *strSource,
54+
size_t count
55+
)
56+
{
57+
UINTN DestMax = MAX_STRING_SIZE;
58+
59+
if (count < MAX_STRING_SIZE) {
60+
DestMax = count + 1;
61+
} else {
62+
count = MAX_STRING_SIZE-1;
63+
}
64+
65+
AsciiStrnCpyS (strDest, DestMax, strSource, (UINTN)count);
66+
67+
return strDest;
68+
}
69+
5070
/**strcmp function. **/
5171
int
5272
strcmp (

CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/DummyOpensslSupport.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -262,26 +262,6 @@ strcpy (
262262
return strDest;
263263
}
264264

265-
char *
266-
strncpy (
267-
char *strDest,
268-
const char *strSource,
269-
size_t count
270-
)
271-
{
272-
UINTN DestMax = MAX_STRING_SIZE;
273-
274-
if (count < MAX_STRING_SIZE) {
275-
DestMax = count + 1;
276-
} else {
277-
count = MAX_STRING_SIZE-1;
278-
}
279-
280-
AsciiStrnCpyS (strDest, DestMax, strSource, (UINTN)count);
281-
282-
return strDest;
283-
}
284-
285265
//
286266
// -- Character Classification Routines --
287267
//

0 commit comments

Comments
 (0)