fix off-by-one error in generator limit

This commit does not add tests that verify the exact limit,
because pinging 100000 localhost addresses takes over 15
minutes on my PC.  I have tested this fix manually.
pull/334/head
Erik Auerswald 4 months ago
parent 54e6f838c3
commit a1509c1b4d

@ -295,7 +295,7 @@ line arguments, and 4 for a system call failure.
=head1 RESTRICTIONS
The number of addresses that can be generated using the C<-g>, C<--generate>
option is limited to 100001.
option is limited to 100000.
If fping was configured with C<--enable-safe-limits>, the following values are
not allowed for non-root users:

@ -1356,7 +1356,7 @@ void add_range(char *start, char *end)
void add_addr_range_ipv4(unsigned long start_long, unsigned long end_long)
{
/* check if generator limit is exceeded */
if (end_long > start_long + MAX_GENERATE) {
if (end_long >= start_long + MAX_GENERATE) {
fprintf(stderr, "%s: -g parameter generates too many addresses\n", prog);
exit(1);
}
@ -3015,7 +3015,7 @@ void usage(int is_error)
fprintf(out, " -c, --count=N count mode: send N pings to each target and report stats\n");
fprintf(out, " -f, --file=FILE read list of targets from a file ( - means stdin)\n");
fprintf(out, " -g, --generate generate target list (only if no -f specified),\n");
fprintf(out, " limited to at most %d targets\n", MAX_GENERATE+1);
fprintf(out, " limited to at most %d targets\n", MAX_GENERATE);
fprintf(out, " (give start and end IP in the target list, or a CIDR address)\n");
fprintf(out, " (ex. %s -g 192.168.1.0 192.168.1.255 or %s -g 192.168.1.0/24)\n", prog, prog);
fprintf(out, " -H, --ttl=N set the IP TTL value (Time To Live hops)\n");

Loading…
Cancel
Save