Skip to content

Commit

Permalink
tools/nut-scanner/nut-scanner.c: handle_arg_cidr(): report ignoring a…
Browse files Browse the repository at this point in the history
… subnet by family before checking for mask length [networkupstools#2244]

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Jul 8, 2024
1 parent c2f5221 commit 58a4e23
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tools/nut-scanner/nut-scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,15 @@ static void handle_arg_cidr(const char *arg_addr, int *auto_nets_ptr)

upsdebugx(5, "Discovering getifaddrs(): %s", msg);

if (!(
(auto_nets == 46
|| (auto_nets == 4 && ifa->ifa_addr->sa_family == AF_INET)
|| (auto_nets == 6 && ifa->ifa_addr->sa_family == AF_INET6) )
)) {
upsdebugx(6, "Subnet ignored: not of the requested address family");
continue;
}

if (masklen_hosts_limit < masklen_hosts) {
/* NOTE: masklen_hosts==0 means
* an exact hit on one address,
Expand All @@ -617,15 +626,6 @@ static void handle_arg_cidr(const char *arg_addr, int *auto_nets_ptr)
continue;
}

if (!(
(auto_nets == 46
|| (auto_nets == 4 && ifa->ifa_addr->sa_family == AF_INET)
|| (auto_nets == 6 && ifa->ifa_addr->sa_family == AF_INET6) )
)) {
upsdebugx(6, "Subnet ignored: not of the requested address family");
continue;
}

/* TODO: also rule out "link-local" address ranges
* so we do not issue billions of worthless scans.
* FIXME: IPv6 may also be a problem, see
Expand Down

0 comments on commit 58a4e23

Please sign in to comment.