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.
| 1815 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap. |
| 1816 | **/ |
| 1817 | RETURN_STATUS |
| 1818 | EFIAPI |
| 1819 | AsciiStrCpyS ( |
| 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 |
no outgoing calls
no test coverage detected