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

Functions

EXPORT constraint_handler_t set_str_constraint_handler_s (constraint_handler_t handler)
 The set_str_constraint_handler_s function sets the runtime-constraint handler to be handler. More...
 
EXPORT void invoke_safe_str_constraint_handler (const char *restrict msg, void *restrict ptr, errno_t error)
 Invokes the currently set constraint handler or the default. More...
 
int handle_str_bos_overload (const char *restrict msg, char *restrict dest, const rsize_t dmax)
 
void handle_str_bos_chk_warn (const char *restrict func, char *restrict dest, const rsize_t dmax, const size_t destbos)
 
void handle_str_src_bos_chk_warn (const char *restrict func, char *restrict dest, const rsize_t smax, const size_t srcbos, const char *srcname, const char *smaxname)
 

Variables

static constraint_handler_t str_handler = NULL
 

Function Documentation

◆ set_str_constraint_handler_s()

EXPORT constraint_handler_t set_str_constraint_handler_s ( constraint_handler_t  handler)

The set_str_constraint_handler_s function sets the runtime-constraint handler to be handler.

The runtime-constraint handler is the function to be called when a library function detects a runtime-constraint violation. Only the most recent handler registered with set_str_constraint_handler_s is called when a runtime-constraint violation occurs. When the handler is called, it is passed the following arguments in the following order:

  1. A pointer to a character string describing the runtime-constraint violation.
  2. A null pointer or a pointer to an implementation defined object.
  3. If the function calling the handler has a return type declared as errno_t, the return value of the function is passed. Otherwise, a positive value of type errno_t is passed. The implementation has a default constraint handler that is used if no calls to the set_constraint_handler_s function have been made. The behavior of the default handler is implementation-defined, and it may cause the program to exit or abort. If the handler argument to set_constraint_handler_s is a null pointer, the implementation default handler becomes the current constraint handler.
Remarks
SPECIFIED IN ISO/IEC JTC1 SC22 WG14 N1172, Programming languages, environments and system software interfaces, Extensions to the C Library, Part I: Bounds-checking interfaces
See also
set_str_constraint_handler_s()

◆ invoke_safe_str_constraint_handler()

EXPORT void invoke_safe_str_constraint_handler ( const char *restrict  msg,
void *restrict  ptr,
errno_t  error 
)

Invokes the currently set constraint handler or the default.

Can be disabled via –disable-constraint-handler

Parameters
*msgPointer to the message describing the error.
*ptrPointer to aassociated data. Can be NULL.
errorThe error code encountered.

◆ handle_str_bos_overload()

int handle_str_bos_overload ( const char *restrict  msg,
char *restrict  dest,
const rsize_t  dmax 
)

◆ handle_str_bos_chk_warn()

void handle_str_bos_chk_warn ( const char *restrict  func,
char *restrict  dest,
const rsize_t  dmax,
const size_t  destbos 
)

◆ handle_str_src_bos_chk_warn()

void handle_str_src_bos_chk_warn ( const char *restrict  func,
char *restrict  dest,
const rsize_t  smax,
const size_t  srcbos,
const char *  srcname,
const char *  smaxname 
)

Variable Documentation

◆ str_handler

constraint_handler_t str_handler = NULL
static