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 <ccoll...@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 }