]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
binman: Detect bad CBFS file types
authorSimon Glass <sjg@chromium.org>
Mon, 8 Jul 2019 20:25:42 +0000 (14:25 -0600)
committerSimon Glass <sjg@chromium.org>
Wed, 24 Jul 2019 19:54:08 +0000 (12:54 -0700)
Detect when an unknown or unsupported file type is specified and report
an error.

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/binman/etype/cbfs.py
tools/binman/ftest.py
tools/binman/test/126_cbfs_bad_type.dts [new file with mode: 0644]

index a46bb98a033b2e7471ad3fa8af56df02160a82e3..175ecae15842d2c17371b09efd6de84c500f90a2 100644 (file)
@@ -190,6 +190,9 @@ class Entry_cbfs(Entry):
             elif entry._type == 'stage':
                 cfile = cbfs.add_file_stage(entry._cbfs_name, data,
                                             entry._cbfs_offset)
+            else:
+                entry.Raise("Unknown cbfs-type '%s' (use 'raw', 'stage')" %
+                            entry._type)
             if cfile:
                 entry._cbfs_file = cfile
                 entry.size = cfile.data_len
index 999d8884acacc3ecdafe4a161c61815f46009c6e..21bea6c9d13a5abf862daa24595ecacd93fc57b3 100644 (file)
@@ -2185,6 +2185,12 @@ class TestFunctional(unittest.TestCase):
             'cbfs/u-boot-dtb:image-pos': 0xb8,
             }, props)
 
+    def testCbfsBadType(self):
+        """Test an image header with a no specified location is detected"""
+        with self.assertRaises(ValueError) as e:
+            self._DoReadFile('126_cbfs_bad_type.dts')
+        self.assertIn("Unknown cbfs-type 'badtype'", str(e.exception))
+
 
 if __name__ == "__main__":
     unittest.main()
diff --git a/tools/binman/test/126_cbfs_bad_type.dts b/tools/binman/test/126_cbfs_bad_type.dts
new file mode 100644 (file)
index 0000000..2cd6fc6
--- /dev/null
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+       #address-cells = <1>;
+       #size-cells = <1>;
+
+       binman {
+               cbfs {
+                       size = <0x100>;
+                       u-boot {
+                               cbfs-type = "badtype";
+                       };
+               };
+       };
+};