summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Albert <albertj@us.ibm.com>2015-03-02 10:28:11 -0600
committerJason Albert <albertj@us.ibm.com>2015-03-02 10:28:11 -0600
commitfc4ee2db9b2ae641de17c5c916997330d07e8e18 (patch)
treee5bdd95b211899052593fdb4e56c6c126a873019
parent5ada898604e71d3d7ba597b59b16b10279b9a177 (diff)
downloadvpdtools-fc4ee2db9b2ae641de17c5c916997330d07e8e18.tar.gz
vpdtools-fc4ee2db9b2ae641de17c5c916997330d07e8e18.zip
Added support for keyword length checking
-rwxr-xr-xcreateVpd.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/createVpd.py b/createVpd.py
index 4583f0d..2c5b79f 100755
--- a/createVpd.py
+++ b/createVpd.py
@@ -202,7 +202,7 @@ for record in manifest.iter("record"):
kwtype = kw.text
if (kw.tag == "kwlen"):
- kwlen = kw.text
+ kwlen = int(kw.text)
if (kw.tag == "kwvalue"):
kwvalue = kw.text
@@ -224,6 +224,17 @@ for record in manifest.iter("record"):
error("The value of the RT keyword \"%s\" does not match the record name \"%s\"" % (kwvalue, recordName))
errorsFound+=1
+ # Check that the length specified isn't longer than the keyword supports
+ # Keywords that start with # are 2 bytes, others are 1 byte
+ if (keywordName[0] == "#"):
+ if (kwlen >= 65535):
+ error("The specified length %d is bigger than the max length 65535 for keyword %s in record %s" % (kwlen, keywordName, recordName))
+ errorsFound+=1
+ else:
+ if (kwlen >= 255):
+ error("The specified length %d is bigger than the max length 255 for keyword %s in record %s" % (kwlen, keywordName, recordName))
+ errorsFound+=1
+
# Verify that the data isn't longer than the length given
# Future checks could include making sure hex data is hex
if (kwtype.lower() == "ascii"):
OpenPOWER on IntegriCloud