1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Fix sign and width issues around max_ips_to_scan. Fixes #2838. Fixes #2836

This commit is contained in:
dmiller
2024-06-04 18:22:17 +00:00
parent e4a4b2854f
commit 03c9f34959
5 changed files with 26 additions and 16 deletions

View File

@@ -285,7 +285,7 @@ bool target_needs_new_hostgroup(Target **targets, int targets_sz, const Target *
The target_expressions array MUST REMAIN VALID IN MEMORY as long as
this class instance is used -- the array is NOT copied.
*/
HostGroupState::HostGroupState(int lookahead, int rnd, int num_random, int argc, const char **argv) {
HostGroupState::HostGroupState(int lookahead, int rnd, unsigned long num_random, int argc, const char **argv) {
assert(lookahead > 0);
this->argc = argc;
this->argv = argv;
@@ -296,7 +296,7 @@ HostGroupState::HostGroupState(int lookahead, int rnd, int num_random, int argc,
current_batch_sz = 0;
next_batch_no = 0;
randomize = rnd;
if (num_random > 0) {
if (num_random >= 0) {
current_group.generate_random_ips(num_random);
}
}
@@ -414,8 +414,8 @@ bail:
}
bool HostGroupState::get_next_host(struct sockaddr_storage *ss, size_t *sslen, struct addrset *exclude_group) {
int num_queued = o.numhosts_scanned + current_batch_sz;
if (o.max_ips_to_scan > 0 && num_queued >= (int)o.max_ips_to_scan) {
unsigned long num_queued = o.numhosts_scanned + current_batch_sz;
if (o.max_ips_to_scan > 0 && num_queued >= o.max_ips_to_scan) {
return false;
}