...
| Code Block | ||
|---|---|---|
| ||
#include <signal.h>
#include <stdlib.h>
#include <string.h>
char *err_msg;
void handler() {
strcpy(err_msg, "SIGINT encountered.");
}
int main() {
signal(SIGINT, handler);
err_msg = malloc(24);
if(err_msg == NULL) {
/* handle error condition */
}
strcpy(err_msg, "No errors yet.");
/* main code loop */
return 0;
}
|
...
| Code Block | ||
|---|---|---|
| ||
#include <signal.h>
#include <stdlib.h>
#include <string.h>
char *err_msg;
volatile sig_atomic_t e_flag = 0;
void handler() {
e_flag = 1;
}
int main() {
signal(SIGINT, handler);
err_msg = malloc(24);
if (err_msg == NULL) {
/* handle error condition */
}
strcpy(err_msg, "No errors yet.");
/* main code loop */
if(e_flag)
strcpy(err_msg, "SIGINT received.");
return 0;
}
|
Risk Assessment
...