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

Function StrCatS

MdePkg/Library/BaseLib/SafeString.c:406–476  ·  view source on GitHub ↗

Appends a copy of the string pointed to by Source (including the terminating null char) to the end of the string pointed to by Destination. This function is similar as strcat_s defined in C11. If Destination is not aligned on a 16-bit boundary, then ASSERT(). If Source is not aligned on a 16-bit boundary, then ASSERT(). If an error would be returned, then the function will also

Source from the content-addressed store, hash-verified

404 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
405**/
406RETURN_STATUS
407EFIAPI
408StrCatS (
409 IN OUT CHAR16 *Destination,
410 IN UINTN DestMax,
411 IN CONST CHAR16 *Source
412 )
413{
414 UINTN DestLen;
415 UINTN CopyLen;
416// UINTN SourceLen;
417
418 ASSERT (((UINTN) Destination & BIT0) == 0);
419 ASSERT (((UINTN) Source & BIT0) == 0);
420
421 //
422 // Let CopyLen denote the value DestMax - StrnLenS(Destination, DestMax) upon entry to StrCatS.
423 //
424 DestLen = StrnLenS (Destination, DestMax); //Slice: DestLen <= DestMax
425 CopyLen = DestMax - DestLen;
426
427 //
428 // 1. Neither Destination nor Source shall be a null pointer.
429 //
430 SAFE_STRING_CONSTRAINT_CHECK ((Destination != NULL), RETURN_INVALID_PARAMETER);
431 SAFE_STRING_CONSTRAINT_CHECK ((Source != NULL), RETURN_INVALID_PARAMETER);
432
433 //
434 // 2. DestMax shall not be greater than RSIZE_MAX.
435 //
436// if (RSIZE_MAX != 0) {
437// SAFE_STRING_CONSTRAINT_CHECK ((DestMax <= RSIZE_MAX), RETURN_INVALID_PARAMETER);
438// if (DestMax > RSIZE_MAX) {
439// DestMax = RSIZE_MAX;
440// }
441// }
442
443 //
444 // 3. DestMax shall not equal zero.
445 //
446 SAFE_STRING_CONSTRAINT_CHECK ((DestMax != 0), RETURN_INVALID_PARAMETER);
447
448 //
449 // 4. CopyLen shall not equal zero.
450 //
451 SAFE_STRING_CONSTRAINT_CHECK ((CopyLen != 0), RETURN_BAD_BUFFER_SIZE);
452
453 //
454 // 5. CopyLen shall be greater than StrnLenS(Source, CopyLen).
455 //
456// SourceLen = StrnLenS (Source, CopyLen); //Slice: SourceLen <= CopyLen
457// SAFE_STRING_CONSTRAINT_CHECK ((CopyLen > SourceLen), RETURN_BUFFER_TOO_SMALL);
458
459 //
460 // 6. Copying shall not take place between objects that overlap.
461 //
462// SAFE_STRING_CONSTRAINT_CHECK (InternalSafeStringNoStrOverlap (Destination, DestMax, (CHAR16 *)Source, SourceLen + 1), RETURN_ACCESS_DENIED);
463

Callers 15

FSInject.cFile · 0.85
CreatePopUpFunction · 0.85
ConvertProcessorToStringFunction · 0.85
BOpt_AppendFileNameFunction · 0.85
CallDriverHealthFunction · 0.85
CallBootManagerFunction · 0.85
ReplaceExtensionFunction · 0.85
Lib.cFile · 0.85
Lib.cFile · 0.85
CreateTabCompletionListFunction · 0.85

Calls 1

StrnLenSFunction · 0.70

Tested by

no test coverage detected