base-files: ipcalc.sh: correctly interpret num parameter
authorLeon M. Busch-George <leon@georgemail.eu>
Fri, 16 Jun 2023 12:53:09 +0000 (14:53 +0200)
committerLeon M. Busch-George <leon@georgemail.eu>
Mon, 25 Sep 2023 13:02:49 +0000 (15:02 +0200)
The start and end addresses are inclusive.
Thus, adding num without substracting one results in num + 1 addresses.
Add the substraction and to implement the documented behaviour.

Signed-off-by: Leon M. Busch-George <leon@georgemail.eu>
package/base-files/files/bin/ipcalc.sh

index 56854b4104105d1ecbebff93e16895e6124823e1..21f84bcaf2e013a404867f44837dcd231afebc3e 100755 (executable)
@@ -69,7 +69,7 @@ BEGIN {
        if (start<limit) start=limit
        if (start==ipaddr) start=ipaddr+1
 
-       end=start+ARGV[4]
+       end=start+ARGV[4]-1
        limit=or(network,compl32(netmask))-1
        if (end>limit) end=limit
        if (end==ipaddr) end=ipaddr-1