safec  3.2
Safe C Library - ISO TR24731 Bounds Checking Interface
strcpyfld_s.c File Reference
#include "safe_str_lib.h"
+ Include dependency graph for strcpyfld_s.c:

Functions

EXPORT errno_t strcpyfld_s (char *dest, rsize_t dmax, const char *src, rsize_t slen)
 The strcpyfld_s function copies slen characters from the character array pointed to by src into the character array pointed to by dest. More...
 

Function Documentation

◆ strcpyfld_s()

EXPORT errno_t strcpyfld_s ( char *  dest,
rsize_t  dmax,
const char *  src,
rsize_t  slen 
)

The strcpyfld_s function copies slen characters from the character array pointed to by src into the character array pointed to by dest.

The copy operation does not stop on the null character as the function copies slen characters.

Remarks
EXTENSION TO ISO/IEC TR 24731-1, Programming languages, environments and system software interfaces, Extensions to the C Library, Part I: Bounds-checking interfaces
Parameters
[out]destpointer to string that will be replaced by src.
[in]dmaxrestricted maximum length of dest
[in]srcpointer to the character array that will be copied to dest
[in]slenmaximum length of src
Precondition
Neither dest nor src shall be a null pointer.
dmax shall not equal zero.
dmax shall not be greater than RSIZE_MAX_STR.
slen shall not equal zero before C11. Since C11 zero is allowed.
slen shall not exceed dmax
Copying shall not take place between objects that overlap.
Returns
If there is a runtime-constraint violation, then if dest is not a null pointer and destmax is greater than zero and not greater than RSIZE_MAX_STR, then strcpyfld_s nulls dest.
Return values
EOKwhen successful operation
ESNULLPwhen dest/src is NULL pointer
ESZEROLwhen dmax = 0. Before C11 also with slen = 0
ESLEMAXwhen dmax > RSIZE_MAX_STR
ESOVRLPwhen strings overlap
ESNOSPCwhen dmax < slen
See also
strcpyfldin_s(), strcpyfldout_s()