You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2020/02/05 00:33:27 UTC

[mynewt-artifact] branch master updated: image: calculate padding when parsing image

This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-artifact.git


The following commit(s) were added to refs/heads/master by this push:
     new 63f9d94  image: calculate padding when parsing image
63f9d94 is described below

commit 63f9d9413e1cbc26209d56ec07e187e2375c8cb2
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Tue Feb 4 16:03:21 2020 -0800

    image: calculate padding when parsing image
    
    When parsing an image file, if the image indicates an extra-long header,
    build a slice of bytes to hold the extra leading padding.  This is
    needed to perform the image hash calculation correctly.
---
 image/parse.go | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/image/parse.go b/image/parse.go
index 0fa7647..85f87e9 100644
--- a/image/parse.go
+++ b/image/parse.go
@@ -239,6 +239,11 @@ func ParseImage(imgData []byte) (Image, error) {
 	img.Tlvs = tlvs
 	img.ProtTlvs = protTlvs
 
+	extra := img.Header.HdrSz - IMAGE_HEADER_SIZE
+	if extra > 0 {
+		img.Pad = make([]byte, extra)
+	}
+
 	return img, nil
 }