diff mbox series

[v2,25/28] binman: Update CheckEntries() for compressed sections

Message ID 20201026234026.1903778-25-sjg@chromium.org
State Accepted
Commit b004bf3906e6f80b80558424e4a3ed8767103e37
Delegated to: Simon Glass
Headers show
Series binman: Support compression of sections | expand

Commit Message

Simon Glass Oct. 26, 2020, 11:40 p.m. UTC
At present this function assumes that the size of a section is at least as
large as its contents. With compression this is often not the case. Relax
this constraint by using the uncompressed size, if available.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 tools/binman/etype/section.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Simon Glass Oct. 30, 2020, 3:33 a.m. UTC | #1
At present this function assumes that the size of a section is at least as
large as its contents. With compression this is often not the case. Relax
this constraint by using the uncompressed size, if available.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v1)

 tools/binman/etype/section.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Applied to u-boot-dm, thanks!
diff mbox series

Patch

diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index 1618bebe4be..b146239b779 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -299,19 +299,21 @@  class Entry_section(Entry):
 
     def CheckEntries(self):
         """Check that entries do not overlap or extend outside the section"""
+        max_size = self.size if self.uncomp_size is None else self.uncomp_size
+
         offset = 0
         prev_name = 'None'
         for entry in self._entries.values():
             entry.CheckEntries()
             if (entry.offset < self._skip_at_start or
                     entry.offset + entry.size > self._skip_at_start +
-                    self.size):
+                    max_size):
                 entry.Raise('Offset %#x (%d) size %#x (%d) is outside the '
                             "section '%s' starting at %#x (%d) "
                             'of size %#x (%d)' %
                             (entry.offset, entry.offset, entry.size, entry.size,
                              self._node.path, self._skip_at_start,
-                             self._skip_at_start, self.size, self.size))
+                             self._skip_at_start, max_size, max_size))
             if entry.offset < offset and entry.size:
                 entry.Raise("Offset %#x (%d) overlaps with previous entry '%s' "
                             "ending at %#x (%d)" %