diff options
| author | Jason Albert <albertj@us.ibm.com> | 2015-03-02 10:28:11 -0600 |
|---|---|---|
| committer | Jason Albert <albertj@us.ibm.com> | 2015-03-02 10:28:11 -0600 |
| commit | fc4ee2db9b2ae641de17c5c916997330d07e8e18 (patch) | |
| tree | e5bdd95b211899052593fdb4e56c6c126a873019 | |
| parent | 5ada898604e71d3d7ba597b59b16b10279b9a177 (diff) | |
| download | vpdtools-fc4ee2db9b2ae641de17c5c916997330d07e8e18.tar.gz vpdtools-fc4ee2db9b2ae641de17c5c916997330d07e8e18.zip | |
Added support for keyword length checking
| -rwxr-xr-x | createVpd.py | 13 |
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"): |

