Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

TR24731-1 provides a consistent mechanism to handle constraints violations of constraints that may only be are discerned at runtime. Section 6.1.4 states:

...

Most functions defined by TR24731-1 include as part of their specification a list of runtime-constraints. Library implementations must verify that the runtime-constraints for a function are not violated by the program. If a runtime-constraint is violated, the currently registered runtime-constraint handler is called.

When the handler is called, it is passed the following arguments in the following order:
#A pointer to a character string describing the runtime-constraint violation.
#A null pointer or a pointer to an implementation defined object.
#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.

A runtime-constraint handler is registered by calling the set_constraint_handler_s() function.

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.

Section 6.1.4 states:

These runtime-constraints are requirements on the program using the library.

...

These runtime constraint handlers mitigate some of the potential insecurity cuased caused by in-band error indicators. See ERR02-A. Avoid in-band error indicators

...