C and C++


LANG.STRUCT.RFCESH : Return from Computational Exception Signal Handler

Summary

Control can return from a function used as a computational exception signal handler. Behavior is undefined when this occurs.

Properties

Class Name Return from Computational Exception Signal Handler
Significance security
Mnemonic LANG.STRUCT.RFCESH
Categories
CERT-C CERT-C:SIG35-C Do not return from a computational exception signal handler
Availability Available for C and C++.
Enabling Checks for this warning class are disabled by default. To enable them, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += allow class="Return from Computational Exception Signal Handler"

Example

#include <signal.h>
#include <stdlib.h>

void handle_return(int s) {
    /* do error handling */
}

void handle_somereturn(int s) {
    /* do error handling */
    if (s < 5){
        exit(1);
    }
}

void handle_noreturn(int s) {
    /* do error handling */
    exit(1);
}

void lang_struct_rfcesh() {
    signal(SIGILL, handle_return);      /* 'Return from Computational Exception Signal Handler' warning issued here */
    signal(SIGILL, handle_somereturn);  /* 'Return from Computational Exception Signal Handler' warning issued here */
    signal(SIGILL, handle_noreturn);                        /* ok: control doesn't return from handle_noreturn() on any path */
}

Relevant Configuration File Parameters

The following configuration file parameters affect checks for this warning class.