acm, xend: Catch bad vlan identifiers
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 23 Sep 2008 11:30:42 +0000 (12:30 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 23 Sep 2008 11:30:42 +0000 (12:30 +0100)
Add code to intercept badly formatted VLAN identifiers or
those that are out of range.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
tools/python/xen/util/xsm/acm/acm.py

index 6c733549c53596f705210cdd4826faee51fbe6b6..c1efdfac0db7fb9f321a8afe013d980ddf5b15b9 100644 (file)
@@ -862,6 +862,15 @@ def unify_resname(resource, mustexist=True):
         if mustexist and not os.path.isfile(resfile):
             err("Invalid resource")
 
+    if typ == "vlan":
+        try:
+            vlan = int(resfile)
+            if vlan < 1 or vlan > 4095:
+                err("VLAN ID %d out of range." % vlan)
+        except Exception, e:
+            err("Invalid VLAN : %s" % resfile)
+
+
     #file: resources must be specified with absolute path
     #vlan resources don't start with '/'
     if typ != "vlan":