diff --git a/boreas/alivedetection.c b/boreas/alivedetection.c index 3df33eeb5..e3449d366 100644 --- a/boreas/alivedetection.c +++ b/boreas/alivedetection.c @@ -71,6 +71,7 @@ scan (alive_test_t alive_test) { int number_of_targets; int number_of_dead_hosts; + int number_of_alive_hosts; pthread_t sniffer_thread_id; GHashTableIter target_hosts_iter; gpointer key, value; @@ -186,9 +187,22 @@ scan (alive_test_t alive_test) stop_sniffer_thread (&scanner, sniffer_thread_id); - /* Send info about dead hosts to ospd-openvas. This is needed for the - * calculation of the progress bar for gsa. */ - number_of_dead_hosts = send_dead_hosts_to_ospd_openvas (scanner.hosts_data); + number_of_dead_hosts = count_difference (scanner.hosts_data->targethosts, + scanner.hosts_data->alivehosts); + number_of_alive_hosts = g_hash_table_size (scanner.hosts_data->alivehosts); + + /* Send number of dead hosts to ospd-openvas. We need to consider the scan + * restrictions.*/ + if (scanner.scan_restrictions->max_scan_hosts_reached) + { + send_dead_hosts_to_ospd_openvas ( + number_of_targets + - (number_of_alive_hosts - scanner.scan_restrictions->max_scan_hosts)); + } + else + { + send_dead_hosts_to_ospd_openvas (number_of_dead_hosts); + } gettimeofday (&end_time, NULL); diff --git a/boreas/boreas_io.c b/boreas/boreas_io.c index 22a8440bc..d9987e8a3 100644 --- a/boreas/boreas_io.c +++ b/boreas/boreas_io.c @@ -327,19 +327,19 @@ handle_scan_restrictions (struct scanner *scanner, gchar *addr_str) * @brief Send the number of dead hosts to ospd-openvas. * * This information is needed for the calculation of the progress bar for gsa in - * ospd-openvas. + * ospd-openvas. The number of dead hosts sent to ospd-openvas may not + * necessarily reflect the acutal number of dead hosts in the target list. * * @param hosts_data Includes all data which is needed for calculating the * number of dead hosts. * * @return number of dead hosts, or -1 in case of an error. */ -int -send_dead_hosts_to_ospd_openvas (struct hosts_data *hosts_data) +void +send_dead_hosts_to_ospd_openvas (int count_dead_hosts) { kb_t main_kb; int maindbid; - int count_dead_hosts; char dead_host_msg_to_ospd_openvas[2048]; maindbid = atoi (prefs_get ("ov_maindbid")); @@ -350,21 +350,14 @@ send_dead_hosts_to_ospd_openvas (struct hosts_data *hosts_data) g_debug ("%s: Could not connect to main_kb for sending dead hosts to " "ospd-openvas.", __func__); - return -1; } - /* Number of targethosts - alivehosts. */ - count_dead_hosts = - count_difference (hosts_data->targethosts, hosts_data->alivehosts); - snprintf (dead_host_msg_to_ospd_openvas, sizeof (dead_host_msg_to_ospd_openvas), "DEADHOST||| ||| ||| |||%d", count_dead_hosts); kb_item_push_str (main_kb, "internal/results", dead_host_msg_to_ospd_openvas); kb_lnk_reset (main_kb); - - return count_dead_hosts; } /** diff --git a/boreas/boreas_io.h b/boreas/boreas_io.h index 6bc74e1c7..7a3017e9d 100644 --- a/boreas/boreas_io.h +++ b/boreas/boreas_io.h @@ -31,8 +31,8 @@ get_host_from_queue (kb_t, gboolean *); void put_finish_signal_on_queue (void *); -int -send_dead_hosts_to_ospd_openvas (struct hosts_data *); +void +send_dead_hosts_to_ospd_openvas (int); void init_scan_restrictions (struct scanner *, int);