safec
3.2
Safe C Library - ISO TR24731 Bounds Checking Interface
|
#include "safe_str_lib.h"
Functions | |
EXPORT errno_t | strerror_s (char *dest, rsize_t dmax, errno_t errnum) |
The strerror_s function returns a pointer to the textual description of the system error code errnum, identical to the description that would be printed by perror(). More... | |
EXPORT size_t | strerrorlen_s (errno_t errnum) |
The strerrorlen_s function returns the untruncated length of the textual description of the system error code errnum , identical to the description that would be printed by perror() . More... | |
The strerror_s
function returns a pointer to the textual description of the system error code errnum, identical to the description that would be printed by perror().
In addition to strerror()
it adds the size of the destination array in order to prevent buffer overflow, and it truncates overlong error messages with "...".
No more than bufsz-1 bytes are written, the buffer is always null-terminated. If the message had to be truncated to fit the buffer and bufsz is greater than 3, then only bufsz-4 bytes are written, and the characters "..." are appended before the null terminator. The behavior is undefined if writing to dest occurs past the end of the array, which can happen when the size of the buffer pointed to by dest is less than the number of characters in the error message which in turn is less than dmax.
[out] | dest | pointer to a user-provided buffer. |
[in] | dmax | restricted maximum length of dest |
[in] | errnum | integer value referring to an error code |
EOK | on success |
ESNULLP | when dest is a NULL pointer |
ESZEROL | when dmax = 0 |
ESLEMAX | when dmax > RSIZE_MAX_STR |
ESLEMIN | when the result would be longer than 4 and dmax < 4 |
EXPORT size_t strerrorlen_s | ( | errno_t | errnum | ) |
The strerrorlen_s
function returns the untruncated length of the textual description of the system error code errnum
, identical to the description that would be printed by perror()
.
[in] | errnum | integer value referring to an error code |