MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / StrnCatS

Function StrnCatS

MdePkg/Library/BaseLib/SafeString.c:511–588  ·  view source on GitHub ↗

Appends not more than Length successive char from the string pointed to by Source to the end of the string pointed to by Destination. If no null char is copied from Source, then Destination[StrLen(Destination) + Length] is always set to null. This function is similar as strncat_s defined in C11. If Destination is not aligned on a 16-bit boundary, then ASSERT(). If Source is n

Source from the content-addressed store, hash-verified

509 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
510**/
511RETURN_STATUS
512EFIAPI
513StrnCatS (
514 IN OUT CHAR16 *Destination,
515 IN UINTN DestMax,
516 IN CONST CHAR16 *Source,
517 IN UINTN Length
518 )
519{
520 UINTN DestLen;
521 UINTN CopyLen;
522 UINTN SourceLen;
523
524 ASSERT (((UINTN) Destination & BIT0) == 0);
525 ASSERT (((UINTN) Source & BIT0) == 0);
526
527 //
528 // Let CopyLen denote the value DestMax - StrnLenS(Destination, DestMax) upon entry to StrnCatS.
529 //
530 DestLen = StrnLenS (Destination, DestMax);
531 CopyLen = DestMax - DestLen;
532
533 //
534 // 1. Neither Destination nor Source shall be a null pointer.
535 //
536 SAFE_STRING_CONSTRAINT_CHECK ((Destination != NULL), RETURN_INVALID_PARAMETER);
537 SAFE_STRING_CONSTRAINT_CHECK ((Source != NULL), RETURN_INVALID_PARAMETER);
538
539 //
540 // 2. Neither DestMax nor Length shall be greater than RSIZE_MAX.
541 //
542// if (RSIZE_MAX != 0) {
543// SAFE_STRING_CONSTRAINT_CHECK ((DestMax <= RSIZE_MAX), RETURN_INVALID_PARAMETER);
544// SAFE_STRING_CONSTRAINT_CHECK ((Length <= RSIZE_MAX), RETURN_INVALID_PARAMETER);
545// }
546
547 //
548 // 3. DestMax shall not equal zero.
549 //
550 SAFE_STRING_CONSTRAINT_CHECK ((DestMax != 0), RETURN_INVALID_PARAMETER);
551
552 //
553 // 4. CopyLen shall not equal zero.
554 //
555 SAFE_STRING_CONSTRAINT_CHECK ((CopyLen != 0), RETURN_BAD_BUFFER_SIZE);
556
557 //
558 // 5. If Length is not less than CopyLen, then CopyLen shall be greater than StrnLenS(Source, CopyLen).
559 //
560 SourceLen = StrnLenS (Source, MIN (CopyLen, Length));
561// if (Length >= CopyLen) {
562// SAFE_STRING_CONSTRAINT_CHECK ((CopyLen > SourceLen), RETURN_BUFFER_TOO_SMALL);
563// }
564
565 //
566 // 6. Copying shall not take place between objects that overlap.
567 //
568 if (SourceLen > Length) {

Callers 15

BdsMemoryTestFunction · 0.85
UpdateConModePageFunction · 0.85
CallDriverHealthFunction · 0.85
CreateTabCompletionListFunction · 0.85
GetExecuatableFileNameFunction · 0.85
GetManFileNameFunction · 0.85
DoStartupScriptFunction · 0.85
DoHelpUpdateFunction · 0.85
MappingListHasTypeFunction · 0.85
AddMappingFromMappingFunction · 0.85
AddMappingFromHandleFunction · 0.85

Calls 1

StrnLenSFunction · 0.70

Tested by 1

BdsMemoryTestFunction · 0.68