aboutsummaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorSteve McIntyre <steve.mcintyre@linaro.org>2014-12-08 16:00:46 +0000
committerSteve McIntyre <steve.mcintyre@linaro.org>2014-12-08 16:00:46 +0000
commit49777e7aa77570f3626893724a6321fac468009e (patch)
tree2ee9030a0380dbb5b4f995940203b2c042e9ff2c /db
parent2d685c7f227a4774e56bf8c1b3dd3fffad7cea14 (diff)
Add length-checking on VLAN names
Change-Id: I92d2cc58b204afd2015df0e15233591e4ae35828
Diffstat (limited to 'db')
-rw-r--r--db/db.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/db/db.py b/db/db.py
index 7c9fc75..378dc35 100644
--- a/db/db.py
+++ b/db/db.py
@@ -106,11 +106,14 @@ class VlanDB:
# Constraints:
# Names and tags must be unique
# Tags must be in the range 1-4095 (802.1q spec)
- # Names can be any free-form text
+ # Names can be any free-form text, length 1-32 characters
def create_vlan(self, name, tag, is_base_vlan):
if int(tag) < 1 or int(tag) > 4095:
- raise InputError("VLAN tag %d is outside of the valid range (1-4095)" % int(tag)
+ raise InputError("VLAN tag %d is outside of the valid range (1-4095)" % int(tag))
+
+ if (len(name) < 1) or (len(name) > 32):
+ raise InputError("VLAN name %s is invalid (must be 1-32 chars)" % name)
vlan_id = self.get_vlan_id_by_name(name)
if vlan_id is not None: