summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-firewall/luasrc/model/cbi
diff options
context:
space:
mode:
authorHannu Nyman <hannu.nyman@iki.fi>2015-08-26 13:51:31 +0300
committerHannu Nyman <hannu.nyman@iki.fi>2015-08-26 13:55:26 +0300
commit34e875b3d35fa1d4dde0a3ec662868213b710c55 (patch)
tree8fcbad489f9fbfd1d85974540d3e6c6168edbed6 /applications/luci-app-firewall/luasrc/model/cbi
parent084d435060f73a8e098c8022a43bd9f5b1fd63ca (diff)
firewall: validate max length of zone name
fw3 sets the maximum length of the zone name to 14 and ignores zone definitions with too long names. http://nbd.name/gitweb.cgi?p=firewall3.git;a=blob;f=zones.h;hb=HEAD#l25 http://nbd.name/gitweb.cgi?p=firewall3.git;a=blob;f=zones.c;hb=HEAD#l195 Add a simple validation to ensure that the new zone name is short enough. This should fix issue #345 Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
Diffstat (limited to 'applications/luci-app-firewall/luasrc/model/cbi')
-rw-r--r--applications/luci-app-firewall/luasrc/model/cbi/firewall/zone-details.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/applications/luci-app-firewall/luasrc/model/cbi/firewall/zone-details.lua b/applications/luci-app-firewall/luasrc/model/cbi/firewall/zone-details.lua
index 3eb95ebb5..46b374440 100644
--- a/applications/luci-app-firewall/luasrc/model/cbi/firewall/zone-details.lua
+++ b/applications/luci-app-firewall/luasrc/model/cbi/firewall/zone-details.lua
@@ -76,6 +76,15 @@ function name.write(self, section, value)
}
end
+function name.validate(self, value)
+ -- fw3 defines 14 as the maximum length of zone name
+ if #value > 14 then
+ return nil, translate("Zone name is too long")
+ else
+ return value
+ end
+end
+
p = {
s:taboption("general", ListValue, "input", translate("Input")),
s:taboption("general", ListValue, "output", translate("Output")),