[edk2] [staging/FmpDevicePkg-master 1/8] BaseTools/Capsule: Add max value checks to Capsule Generation tools

Kinney, Michael D posted 8 patches 6 years, 1 month ago
[edk2] [staging/FmpDevicePkg-master 1/8] BaseTools/Capsule: Add max value checks to Capsule Generation tools
Posted by Kinney, Michael D 6 years, 1 month ago
https://bugzilla.tianocore.org/show_bug.cgi?id=1021
https://bugzilla.tianocore.org/show_bug.cgi?id=1022
https://bugzilla.tianocore.org/show_bug.cgi?id=1026

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
---
 BaseTools/Source/Python/Capsule/GenerateCapsule.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/BaseTools/Source/Python/Capsule/GenerateCapsule.py b/BaseTools/Source/Python/Capsule/GenerateCapsule.py
index 4018dc0420..5398c12a9c 100644
--- a/BaseTools/Source/Python/Capsule/GenerateCapsule.py
+++ b/BaseTools/Source/Python/Capsule/GenerateCapsule.py
@@ -298,6 +298,12 @@ if __name__ == '__main__':
                 parser.error ('--capflag PopulateSystemTable also requires --capflag PersistAcrossReset')
             if 'InitiateReset' in args.CapsuleFlag:
                 parser.error ('--capflag InitiateReset also requires --capflag PersistAcrossReset')
+        if args.CapsuleOemFlag > 0xFFFF:
+            parser.error ('--capoemflag must be an integer between 0x0000 and 0xffff')
+        if args.HardwareInstance > 0xFFFFFFFFFFFFFFFF:
+            parser.error ('--hardware-instance must be an integer in range 0x0..0xffffffffffffffff')
+        if args.MonotonicCount > 0xFFFFFFFFFFFFFFFF:
+            parser.error ('--monotonic-count must be an integer in range 0x0..0xffffffffffffffff')
 
     UseSignTool = args.SignToolPfxFile is not None
     UseOpenSsl  = (args.OpenSslSignerPrivateCertFile is not None and
@@ -319,6 +325,10 @@ if __name__ == '__main__':
         if args.Encode and (UseSignTool or UseOpenSsl):
             if args.FwVersion is None or args.LowestSupportedVersion is None:
                 parser.error ('the following options are required: --fw-version, --lsv')
+            if args.FwVersion > 0xFFFFFFFF:
+                parser.error ('--fw-version must be an integer in range 0x0..0xffffffff')
+            if args.LowestSupportedVersion > 0xFFFFFFFF:
+                parser.error ('--lsv must be an integer in range 0x0..0xffffffff')
 
         if UseSignTool:
             args.SignToolPfxFile.close()
-- 
2.14.2.windows.3

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel