From 00a20335ba2bac4cc33048464ba4bab070309db7 Mon Sep 17 00:00:00 2001 From: "Leon M. George" Date: Thu, 5 May 2022 23:19:53 +0200 Subject: [PATCH] base-files: ipcalc.sh: check for params before calculating start/end With this patch, ipcalc only calculates range boundaries if the corresponding parameters are supplied. Signed-off-by: Leon M. George --- package/base-files/files/bin/ipcalc.sh | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/package/base-files/files/bin/ipcalc.sh b/package/base-files/files/bin/ipcalc.sh index 5d5eac3ea8..9b2c4d2afc 100755 --- a/package/base-files/files/bin/ipcalc.sh +++ b/package/base-files/files/bin/ipcalc.sh @@ -46,14 +46,6 @@ BEGIN { network=and(ipaddr,netmask) broadcast=or(network,compl32(netmask)) - start=or(network,and(ip2int(ARGV[3]),compl32(netmask))) - limit=network+1 - if (startlimit) end=limit - print "IP="int2ip(ipaddr) print "NETMASK="int2ip(netmask) print "BROADCAST="int2ip(broadcast) @@ -63,9 +55,18 @@ BEGIN { # range calculations: # ipcalc - if (ARGC > 3) { - print "START="int2ip(start) - print "END="int2ip(end) - } + if (ARGC <= 3) + exit(0) + + start=or(network,and(ip2int(ARGV[3]),compl32(netmask))) + limit=network+1 + if (startlimit) end=limit + + print "START="int2ip(start) + print "END="int2ip(end) } EOF -- 2.30.2