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 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 ASSERT(). If an er
| 224 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap. |
| 225 | **/ |
| 226 | RETURN_STATUS |
| 227 | EFIAPI |
| 228 | StrCpyS ( |
| 229 | OUT CHAR16 *Destination, |
| 230 | IN UINTN DestMax, |
| 231 | IN CONST CHAR16 *Source |
| 232 | ) |
| 233 | { |
| 234 | // UINTN SourceLen; |
| 235 | |
| 236 | ASSERT (((UINTN) Destination & BIT0) == 0); |
| 237 | ASSERT (((UINTN) Source & BIT0) == 0); |
| 238 | |
| 239 | // |
| 240 | // 1. Neither Destination nor Source shall be a null pointer. |
| 241 | // |
| 242 | SAFE_STRING_CONSTRAINT_CHECK ((Destination != NULL), RETURN_INVALID_PARAMETER); |
| 243 | SAFE_STRING_CONSTRAINT_CHECK ((Source != NULL), RETURN_INVALID_PARAMETER); |
| 244 | |
| 245 | // |
| 246 | // 2. DestMax shall not be greater than RSIZE_MAX. |
| 247 | // |
| 248 | if (RSIZE_MAX != 0) { |
| 249 | SAFE_STRING_CONSTRAINT_CHECK ((DestMax <= RSIZE_MAX), RETURN_INVALID_PARAMETER); |
| 250 | } |
| 251 | |
| 252 | // |
| 253 | // 3. DestMax shall not equal zero. |
| 254 | // |
| 255 | SAFE_STRING_CONSTRAINT_CHECK ((DestMax != 0), RETURN_INVALID_PARAMETER); |
| 256 | |
| 257 | // |
| 258 | // 4. DestMax shall be greater than StrnLenS(Source, DestMax). |
| 259 | // |
| 260 | // SourceLen = StrnLenS (Source, DestMax); |
| 261 | // SAFE_STRING_CONSTRAINT_CHECK ((DestMax > SourceLen), RETURN_BUFFER_TOO_SMALL); |
| 262 | //Slice: nonsense because of StrnLenS result always <= DestMax |
| 263 | |
| 264 | // |
| 265 | // 5. Copying shall not take place between objects that overlap. |
| 266 | // |
| 267 | // SAFE_STRING_CONSTRAINT_CHECK (InternalSafeStringNoStrOverlap (Destination, DestMax, (CHAR16 *)Source, SourceLen + 1), RETURN_ACCESS_DENIED); |
| 268 | //Slice: relax |
| 269 | |
| 270 | // |
| 271 | // The StrCpyS function copies the string pointed to by Source (including the terminating |
| 272 | // null character) into the array pointed to by Destination. |
| 273 | // |
| 274 | while ((*Source != 0) && (--DestMax > 0)) { |
| 275 | *(Destination++) = *(Source++); |
| 276 | } |
| 277 | *Destination = 0; |
| 278 | |
| 279 | return RETURN_SUCCESS; |
| 280 | } |
| 281 | |
| 282 | /** |
| 283 | Copies not more than Length successive char from the string pointed to by |
no outgoing calls
no test coverage detected