[Autosec-devel] sonar/plugins rfc793.c,1.30,1.31 network_icmp.c,1.32,1.33
Brought to you by:
red0x
From: <re...@us...> - 2003-12-06 00:14:07
|
Update of /cvsroot/autosec/sonar/plugins In directory sc8-pr-cvs1:/tmp/cvs-serv4090/plugins Modified Files: rfc793.c network_icmp.c Log Message: Signals update, inorder to avoid segfaults on ctrl-C's Index: rfc793.c =================================================================== RCS file: /cvsroot/autosec/sonar/plugins/rfc793.c,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** rfc793.c 5 Dec 2003 22:42:17 -0000 1.30 --- rfc793.c 6 Dec 2003 00:14:04 -0000 1.31 *************** *** 24,27 **** --- 24,30 ---- #include "rfc793.h" #include "error.h" + #ifdef HAVE_CONFIG_H + # include "config.h" + #endif static const char rcsid[] = *************** *** 61,64 **** --- 64,68 ---- static int send_ipv4(int sox, u_char * pkt, size_t len, struct net_tuple *nt); static const char *unreach_codes(int code); + static RETSIGTYPE sig_handler(int i); /** @fn plugin_init(void *in_data) *************** *** 513,516 **** --- 517,525 ---- assert(mthis->resolve != NULL); + /* signals, baby */ + signal(SIGTERM, sig_handler); + signal(SIGINT, sig_handler); + signal(SIGHUP, sig_handler); + signal(SIGSEGV, sig_handler); /* make us a list */ results = (result_t *) malloc(sizeof(result_t)); *************** *** 525,529 **** { /* dont do anything up here, or we'll eat CPU */ ! tv.tv_usec = 0; tv.tv_sec = 0; FD_ZERO(&rfds); --- 534,538 ---- { /* dont do anything up here, or we'll eat CPU */ ! tv.tv_usec = 0; tv.tv_sec = 0; FD_ZERO(&rfds); *************** *** 646,650 **** res.user_data = NULL; num_res++; ! /* XXX: we don't always output, do the log function maybe? */ mthis->message ("%s[%s]:%d online & UNfiltered: range: %lu ms ttl: %d size: %d\n", --- 655,659 ---- res.user_data = NULL; num_res++; ! mthis->message ("%s[%s]:%d online & UNfiltered: range: %lu ms ttl: %d size: %d\n", *************** *** 1007,1009 **** --- 1016,1031 ---- } return "unknown"; + } + + static RETSIGTYPE sig_handler(int i) + { + switch(i) + { + case SIGSEGV: + err_msg("oops! ACK scan seg faulted.\n"); + abort(); + break; + } + /* just close the thread and be done with it */ + pthread_exit(NULL); } Index: network_icmp.c =================================================================== RCS file: /cvsroot/autosec/sonar/plugins/network_icmp.c,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** network_icmp.c 5 Dec 2003 22:39:30 -0000 1.32 --- network_icmp.c 6 Dec 2003 00:14:04 -0000 1.33 *************** *** 26,29 **** --- 26,32 ---- #include "network_icmp.h" #include "error.h" + #ifdef HAVE_CONFIG_H + # include "config.h" + #endif static const char rcsid[] = *************** *** 75,78 **** --- 78,82 ---- static const char *respstr(int type); static const char *unreach_codes(int code); + static RETSIGTYPE sig_handler(int i); /** @fn plugin_init(void *in_data) *************** *** 681,684 **** --- 685,693 ---- int psuedo = false; + /* signals, baby */ + signal(SIGTERM, sig_handler); + signal(SIGINT, sig_handler); + signal(SIGHUP, sig_handler); + signal(SIGSEGV, sig_handler); /* make us a list */ results = (result_t *) malloc(sizeof(result_t)); *************** *** 1038,1039 **** --- 1047,1060 ---- } + static RETSIGTYPE sig_handler(int i) + { + switch(i) + { + case SIGSEGV: + err_msg("oops! ACK scan seg faulted.\n"); + abort(); + break; + } + /* just close the thread and be done with it */ + pthread_exit(NULL); + } |