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

Functions

EXPORT errno_t strcat_s (char *restrict dest, rsize_t dmax, const char *restrict src)
 The strcat_s function appends a copy of the string pointed to by src (including the terminating null character) to the end of the string pointed to by dest. More...
 

Function Documentation

◆ strcat_s()

EXPORT errno_t strcat_s ( char *restrict  dest,
rsize_t  dmax,
const char *restrict  src 
)

The strcat_s function appends a copy of the string pointed to by src (including the terminating null character) to the end of the string pointed to by dest.

The initial character from src overwrites the null character at the end ofdest.

All elements following the terminating null character (if any) written by strcat_s in the array of dmax characters pointed to by dest take unspeciļ¬ed values when strcat_s returns. With SAFECLIB_STR_NULL_SLACK defined the rest is cleared with NULL bytes.

Remarks
SPECIFIED IN
  • C11 standard (ISO/IEC 9899:2011): K.3.7.2.1 The strcat_s function (p: 617-618) http://en.cppreference.com/w/c/string/byte/strcat
  • ISO/IEC TR 24731, 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 extended by src if dmax allows. The string is null terminated. If the resulting concatenated string is less than dmax, the remaining slack space is nulled.
[in]dmaxrestricted maximum length of the resulting dest, including the null
[in]srcpointer to the string that will be concatenaed to string dest
Precondition
Neither dest nor src shall be a null pointer
dmax shall not equal zero
dmax shall not be greater than RSIZE_MAX_STR
dmax shall be greater than strnlen_s(src,m).
Copying shall not take place between objects that overlap
Note
C11 uses RSIZE_MAX, not RSIZE_MAX_STR.
Returns
If there is a runtime-constraint violation, then if dest is not a null pointer and dmax is greater than zero and not greater than RSIZE_MAX_STR, then strcat_s nulls dest.
Return values
EOKwhen successful operation, all the characters from src were appended to dest and the result in dest is null terminated.
ESNULLPwhen dest or src is a NULL pointer
ESZEROLwhen dmax = 0
ESLEMAXwhen dmax > RSIZE_MAX_STR
ESUNTERMwhen dest not terminated in the first dmax bytes
ESOVRLPwhen src overlaps with dest
See also
strncat_s(), strcpy_s(), strncpy_s()