@@ -1083,9 +1083,44 @@ apply_hosts_preferences_ordering (gvm_hosts_t *hosts)
1083
1083
g_debug ("hosts_ordering: Sequential." );
1084
1084
}
1085
1085
1086
- static void
1086
+ static int
1087
1087
apply_hosts_reverse_lookup_preferences (gvm_hosts_t * hosts )
1088
1088
{
1089
+ #ifdef FEATURE_REVERSE_LOOKUP_EXCLUDED
1090
+ const char * exclude_hosts = prefs_get ("exclude_hosts" );
1091
+ int hosts_excluded = 0 ;
1092
+
1093
+ if (prefs_get_bool ("reverse_lookup_unify" ))
1094
+ {
1095
+ gvm_hosts_t * excluded ;
1096
+
1097
+ excluded = gvm_hosts_reverse_lookup_unify_excluded (hosts );
1098
+ g_debug ("reverse_lookup_unify: Skipped %lu host(s)." , excluded -> count );
1099
+
1100
+ // Get the amount of hosts which are excluded now for this option,
1101
+ // but they are already in the exclude list.
1102
+ // This is to avoid issues with the scan progress calculation, since
1103
+ // the amount of excluded host could be duplicated.
1104
+ hosts_excluded += gvm_hosts_exclude (excluded , exclude_hosts );
1105
+
1106
+ gvm_hosts_free (excluded );
1107
+ }
1108
+
1109
+ if (prefs_get_bool ("reverse_lookup_only" ))
1110
+ {
1111
+ gvm_hosts_t * excluded ;
1112
+
1113
+ excluded = gvm_hosts_reverse_lookup_only_excluded (hosts );
1114
+ g_debug ("reverse_lookup_unify: Skipped %lu host(s)." , excluded -> count );
1115
+ // Get the amount of hosts which are excluded now for this option,
1116
+ // but they are already in the exclude list.
1117
+ // This is to avoid issues with the scan progress calculation, since
1118
+ // the amount of excluded host could be duplicated.
1119
+ hosts_excluded += gvm_hosts_exclude (excluded , exclude_hosts );
1120
+ gvm_hosts_free (excluded );
1121
+ }
1122
+ return exclude_hosts ? hosts_excluded : 0 ;
1123
+ #else
1089
1124
/* Reverse-lookup unify ? */
1090
1125
if (prefs_get_bool ("reverse_lookup_unify" ))
1091
1126
g_debug ("reverse_lookup_unify: Skipped %d host(s)." ,
@@ -1095,6 +1130,9 @@ apply_hosts_reverse_lookup_preferences (gvm_hosts_t *hosts)
1095
1130
if (prefs_get_bool ("reverse_lookup_only" ))
1096
1131
g_debug ("reverse_lookup_only: Skipped %d host(s)." ,
1097
1132
gvm_hosts_reverse_lookup_only (hosts ));
1133
+
1134
+ return 0 ;
1135
+ #endif
1098
1136
}
1099
1137
1100
1138
static int
@@ -1311,7 +1349,9 @@ attack_network (struct scan_globals *globals)
1311
1349
1312
1350
/* Apply Hosts preferences. */
1313
1351
apply_hosts_preferences_ordering (hosts );
1314
- apply_hosts_reverse_lookup_preferences (hosts );
1352
+
1353
+ int already_excluded = 0 ;
1354
+ already_excluded = apply_hosts_reverse_lookup_preferences (hosts );
1315
1355
1316
1356
#ifdef FEATURE_HOSTS_ALLOWED_ONLY
1317
1357
// Remove hosts which are denied and/or keep the ones in the allowed host
@@ -1322,7 +1362,7 @@ attack_network (struct scan_globals *globals)
1322
1362
1323
1363
/* Send the hosts count to the client, after removing duplicated and
1324
1364
* unresolved hosts.*/
1325
- sprintf (buf , "%d" , gvm_hosts_count (hosts ));
1365
+ sprintf (buf , "%d" , gvm_hosts_count (hosts ) + already_excluded );
1326
1366
connect_main_kb (& main_kb );
1327
1367
message_to_client (main_kb , buf , NULL , NULL , "HOSTS_COUNT" );
1328
1368
kb_lnk_reset (main_kb );
0 commit comments