32 #include "safeclib_private.h" 33 #include "safe_str_constraint.h" 34 #include "safe_str_lib.h" 83 strcpy_s (
char * restrict dest, rsize_t dmax,
const char * restrict src)
87 const char *overlap_bumper;
92 return RCNEGATE(ESNULLP);
98 return RCNEGATE(ESZEROL);
101 if (dmax > RSIZE_MAX_STR) {
104 return RCNEGATE(ESLEMAX);
108 #ifdef SAFECLIB_STR_NULL_SLACK 110 while (dmax) { *dest =
'\0'; dmax--; dest++; }
116 return RCNEGATE(ESNULLP);
120 return RCNEGATE(EOK);
128 overlap_bumper = src;
131 if (dest == overlap_bumper) {
132 handle_error(orig_dest, orig_dmax,
"strcpy_s: " 133 "overlapping objects",
135 return RCNEGATE(ESOVRLP);
140 #ifdef SAFECLIB_STR_NULL_SLACK 142 while (dmax) { *dest =
'\0'; dmax--; dest++; }
144 return RCNEGATE(EOK);
153 overlap_bumper = dest;
156 if (src == overlap_bumper) {
157 handle_error(orig_dest, orig_dmax,
"strcpy_s: " 158 "overlapping objects",
160 return RCNEGATE(ESOVRLP);
165 #ifdef SAFECLIB_STR_NULL_SLACK 167 while (dmax) { *dest =
'\0'; dmax--; dest++; }
169 return RCNEGATE(EOK);
182 handle_error(orig_dest, orig_dmax,
"strcpy_s: not " 183 "enough space for src",
185 return RCNEGATE(ESNOSPC);
errno_t strcpy_s(char *restrict dest, rsize_t dmax, const char *restrict src)
The strcpy_s function copies the string pointed to by src (including the terminating null character) ...
void invoke_safe_str_constraint_handler(const char *msg, void *ptr, errno_t error)
Invokes the currently set constraint handler or the default.