Skip to content

Commit

Permalink
CryptoPkg/BaseCryptLibMbedTls : Add strncpy() support to SecCryptLib
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
AmyChan-Intel authored and mergify[bot] committed Jan 11, 2025
1 parent c0533b7 commit 11cffd9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
20 changes: 20 additions & 0 deletions CryptoPkg/Library/BaseCryptLibMbedTls/SysCall/CrtWrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 --
//
Expand Down

0 comments on commit 11cffd9

Please sign in to comment.