...
In this noncompliant code example, if the given user input is 0, the division operation sends a SIGFPE
signal to the program.:
Code Block | ||||
---|---|---|---|---|
| ||||
#include<signal.h> #include<stddef.h> #include<stdlib.h> volatile sig_atomic_t denom; void sighandle(int s){ /* Fix the offending volatile */ if (denom == 0) { denom = 1; } /* Everything is ok */ return; } int main(int argc, char *argv[]){ int result = 0; if (argc < 2) { return 0; } denom = (int)strtol(argv[1], (char **)NULL, 10); signal(SIGFPE,(*sighandle)); result = 100/denom; return 0; } |
...