diff --git a/alert_parser.c b/alert_parser.c index b32bc21..8c603b9 100644 --- a/alert_parser.c +++ b/alert_parser.c @@ -96,7 +96,14 @@ AI_alerts_pool_thread ( void *arg ) continue; if ( pthread_create ( &serializer_thread, NULL, AI_serializer_thread, NULL ) != 0 ) + { AI_fatal_err ( "Failed to create the alerts' serializer thread", __FILE__, __LINE__ ); + } + + /* if ( pthread_join ( serializer_thread, NULL ) != 0 ) */ + /* { */ + /* AI_fatal_err ( "Could not join the alerts' serializer thread", __FILE__, __LINE__ ); */ + /* } */ } pthread_exit ((void*) 0); @@ -163,7 +170,9 @@ AI_file_alertparser_thread ( void* arg ) /* Initialize the thread for managing the serialization of alerts' pool */ if ( pthread_create ( &alerts_pool_thread, NULL, AI_alerts_pool_thread, NULL ) != 0 ) + { AI_fatal_err ( "Failed to create the alerts' pool management thread", __FILE__, __LINE__ ); + } while ( 1 ) { @@ -285,12 +294,21 @@ AI_file_alertparser_thread ( void* arg ) } if ( pthread_create ( &serializer_thread, NULL, AI_serializer_thread, alert ) != 0 ) + { AI_fatal_err ( "Failed to create the alerts' serializer thread", __FILE__, __LINE__ ); + } + if ( pthread_join ( serializer_thread, NULL ) != 0 ) + { + AI_fatal_err ( "Failed to join the alerts' serializer thread", __FILE__, __LINE__ ); + } + if ( config->outdbtype != outdb_none ) { if ( pthread_create ( &db_thread, NULL, AI_store_alert_to_db_thread, alert ) != 0 ) + { AI_fatal_err ( "Failed to create the alert to db storing thread", __FILE__, __LINE__ ); + } } in_alert = false; diff --git a/db.c b/db.c index 0006749..817d179 100644 --- a/db.c +++ b/db.c @@ -71,7 +71,9 @@ AI_db_alertparser_thread ( void *arg ) /* Initialize the thread for managing the serialization of alerts' pool */ if ( pthread_create ( &alerts_pool_thread, NULL, AI_alerts_pool_thread, NULL ) != 0 ) + { AI_fatal_err ( "Failed to create the alerts' pool management thread", __FILE__, __LINE__ ); + } while ( 1 ) { @@ -221,7 +223,9 @@ AI_db_alertparser_thread ( void *arg ) latest_time = time ( NULL ); if ( pthread_create ( &serializer_thread, NULL, AI_serializer_thread, alert ) != 0 ) + { AI_fatal_err ( "Failed to create the alerts' serializer thread", __FILE__, __LINE__ ); + } } DB_close(); diff --git a/mysql.c b/mysql.c index ec0c56d..c7cbdb0 100644 --- a/mysql.c +++ b/mysql.c @@ -130,6 +130,12 @@ mysql_do_query ( const char *query ) unsigned long mysql_do_escape_string ( char **to, const char *from, unsigned long length ) { + if ( !from ) + return 0; + + if ( strlen ( from ) == 0 ) + return 0; + return mysql_real_escape_string ( db, *to, from, length ); } @@ -174,6 +180,12 @@ mysql_do_out_query ( const char *query ) unsigned long mysql_do_out_escape_string ( char **to, const char *from, unsigned long length ) { + if ( !from ) + return 0; + + if ( strlen ( from ) == 0 ) + return 0; + return mysql_real_escape_string ( outdb, *to, from, length ); } diff --git a/outdb.c b/outdb.c index 378b61c..b8455b7 100644 --- a/outdb.c +++ b/outdb.c @@ -117,6 +117,7 @@ AI_store_alert_to_db_thread ( void *arg ) { pthread_mutex_unlock ( &outdb_mutex ); pthread_exit ((void*) 0); + return (void*) 0; } latest_ip_hdr_id = strtoul ( row[0], NULL, 10 ); @@ -147,12 +148,14 @@ AI_store_alert_to_db_thread ( void *arg ) _dpd.logMsg ( "AIPreproc: Warning: error in executing query: '%s'\n", query ); pthread_mutex_unlock ( &outdb_mutex ); pthread_exit ((void*) 0); + return (void*) 0; } if ( !( row = (DB_row) DB_fetch_row ( res ))) { pthread_mutex_unlock ( &outdb_mutex ); pthread_exit ((void*) 0); + return (void*) 0; } latest_tcp_hdr_id = strtoul ( row[0], NULL, 10 ); @@ -213,12 +216,14 @@ AI_store_alert_to_db_thread ( void *arg ) _dpd.logMsg ( "AIPreproc: Warning: error in executing query: '%s'\n", query ); pthread_mutex_unlock ( &outdb_mutex ); pthread_exit ((void*) 0); + return (void*) 0; } if ( !( row = (DB_row) DB_fetch_row ( res ))) { pthread_mutex_unlock ( &outdb_mutex ); pthread_exit ((void*) 0); + return (void*) 0; } latest_alert_id = strtoul ( row[0], NULL, 10 );