[openwrt/openwrt] base-files: ipcalc.sh: don't include own address in range
LEDE Commits
lede-commits at lists.infradead.org
Tue Feb 7 12:09:34 PST 2023
ansuel pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/4fe106afd1870cfeb6a45d40f1dbb69e890f1756
commit 4fe106afd1870cfeb6a45d40f1dbb69e890f1756
Author: Leon M. George <leon at georgemail.eu>
AuthorDate: Thu May 5 23:47:47 2022 +0200
base-files: ipcalc.sh: don't include own address in range
Make sure our own address doesn't lie in the calculated range.
Signed-off-by: Leon M. George <leon at georgemail.eu>
---
package/base-files/files/bin/ipcalc.sh | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/package/base-files/files/bin/ipcalc.sh b/package/base-files/files/bin/ipcalc.sh
index 9b2c4d2afc..66d37952de 100755
--- a/package/base-files/files/bin/ipcalc.sh
+++ b/package/base-files/files/bin/ipcalc.sh
@@ -61,10 +61,17 @@ BEGIN {
start=or(network,and(ip2int(ARGV[3]),compl32(netmask)))
limit=network+1
if (start<limit) start=limit
+ if (start==ipaddr) start=ipaddr+1
end=start+ARGV[4]
limit=or(network,compl32(netmask))-1
if (end>limit) end=limit
+ if (end==ipaddr) end=ipaddr-1
+
+ if (ipaddr > start && ipaddr < end) {
+ print "ipaddr inside range" > "/dev/stderr"
+ exit(1)
+ }
print "START="int2ip(start)
print "END="int2ip(end)
More information about the lede-commits
mailing list