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

Function AsciiStrCpyS

MdePkg/Library/BaseLib/SafeString.c:1817–1866  ·  view source on GitHub ↗

Copies the string pointed to by Source (including the terminating null char) to the array pointed to by Destination. This function is similar as strcpy_s defined in C11. If an error would be returned, then the function will also ASSERT(). If an error is returned, then the Destination is unmodified. @param Destination A pointer to a Null-terminated Ascii string.

Source from the content-addressed store, hash-verified

1815 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
1816**/
1817RETURN_STATUS
1818EFIAPI
1819AsciiStrCpyS (
1820 OUT CHAR8 *Destination,
1821 IN UINTN DestMax,
1822 IN CONST CHAR8 *Source
1823 )
1824{
1825// UINTN SourceLen;
1826
1827 //
1828 // 1. Neither Destination nor Source shall be a null pointer.
1829 //
1830 SAFE_STRING_CONSTRAINT_CHECK ((Destination != NULL), RETURN_INVALID_PARAMETER);
1831 SAFE_STRING_CONSTRAINT_CHECK ((Source != NULL), RETURN_INVALID_PARAMETER);
1832
1833 //
1834 // 2. DestMax shall not be greater than ASCII_RSIZE_MAX.
1835 //
1836// if (ASCII_RSIZE_MAX != 0) {
1837// SAFE_STRING_CONSTRAINT_CHECK ((DestMax <= ASCII_RSIZE_MAX), RETURN_INVALID_PARAMETER);
1838// }
1839
1840 //
1841 // 3. DestMax shall not equal zero.
1842 //
1843 SAFE_STRING_CONSTRAINT_CHECK ((DestMax != 0), RETURN_INVALID_PARAMETER);
1844
1845 //
1846 // 4. DestMax shall be greater than AsciiStrnLenS(Source, DestMax).
1847 //
1848// SourceLen = AsciiStrnLenS (Source, DestMax);
1849// SAFE_STRING_CONSTRAINT_CHECK ((DestMax > SourceLen), RETURN_BUFFER_TOO_SMALL);
1850
1851 //
1852 // 5. Copying shall not take place between objects that overlap.
1853 //
1854// SAFE_STRING_CONSTRAINT_CHECK (InternalSafeStringNoAsciiStrOverlap (Destination, DestMax, (CHAR8 *)Source, SourceLen + 1), RETURN_ACCESS_DENIED);
1855
1856 //
1857 // The AsciiStrCpyS function copies the string pointed to by Source (including the terminating
1858 // null character) into the array pointed to by Destination.
1859 //
1860 while ((*Source != 0) && (--DestMax > 0)) {
1861 *(Destination++) = *(Source++);
1862 }
1863 *Destination = 0;
1864
1865 return RETURN_SUCCESS;
1866}
1867
1868/**
1869 Copies not more than Length successive char from the string pointed to by

Callers 15

devprop_add_listFunction · 0.85
GetPlistHexValueFunction · 0.85
getDDRSerialFunction · 0.85
SetDMISettingsForModelFunction · 0.85
strcpyFunction · 0.85
nsvg__parseUseFunction · 0.85
parsePatternFunction · 0.85
nsvg__parseSymbolFunction · 0.85
nsvg__parseGroupFunction · 0.85
nsvg__parseFontFunction · 0.85
nsvg__parseFontFaceFunction · 0.85
InsertStringPackageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected