summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-splash
diff options
context:
space:
mode:
authorManuel Munz <freifunk@somakoma.de>2013-10-16 19:48:23 +0000
committerManuel Munz <freifunk@somakoma.de>2013-10-16 19:48:23 +0000
commite966cfea23740e36f94c359506e7412da38af4fd (patch)
tree3f55a1ba36f6c514b601c85ffd2bf33d468820d8 /applications/luci-splash
parentb8fe93a8368223da2ca9b56f0a1ca1b1e3740cd9 (diff)
applications/luci-splash: Add a filter for arguments, only allow valid mac and ip addresses
Diffstat (limited to 'applications/luci-splash')
-rwxr-xr-xapplications/luci-splash/root/usr/sbin/luci-splash26
1 files changed, 26 insertions, 0 deletions
diff --git a/applications/luci-splash/root/usr/sbin/luci-splash b/applications/luci-splash/root/usr/sbin/luci-splash
index de5332330..a7954211b 100755
--- a/applications/luci-splash/root/usr/sbin/luci-splash
+++ b/applications/luci-splash/root/usr/sbin/luci-splash
@@ -106,6 +106,26 @@ function get_filter_handle(parent, direction, device, mac)
return handle
end
+function macvalid(mac)
+ if mac and mac:match(
+ "^[a-fA-F0-9][a-fA-F0-9]:[a-fA-F0-9][a-fA-F0-9]:" ..
+ "[a-fA-F0-9][a-fA-F0-9]:[a-fA-F0-9][a-fA-F0-9]:" ..
+ "[a-fA-F0-9][a-fA-F0-9]:[a-fA-F0-9][a-fA-F0-9]$"
+ ) then
+ return true
+ end
+
+ return false
+end
+
+function ipvalid(ipaddr)
+ if ipaddr then
+ return ip.IPv4(ipaddr) and true or false
+ end
+
+ return false
+end
+
function main(argv)
local cmd = table.remove(argv, 1)
local arg = argv[1]
@@ -116,6 +136,12 @@ function main(argv)
if ( cmd == "lease" or cmd == "add-rules" or cmd == "remove" or
cmd == "whitelist" or cmd == "blacklist" or cmd == "status" ) and #argv > 0
then
+ if not (macvalid(arg) or ipvalid(arg)) then
+ print("Invalid argument. The second argument must " ..
+ "be a valid IPv4 or Mac Address.")
+ os.exit(1)
+ end
+
lock()
local arp_cache = net.arptable()