From 07adcec559df5352e233b5f4aeea1fc5c87be22c Mon Sep 17 00:00:00 2001 From: DarthSim Date: Thu, 9 Jul 2020 18:24:28 +0600 Subject: [PATCH] Fix HEIF/HEIC header parsing bug --- CHANGELOG.md | 1 + imagemeta/heic.go | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8781d567..50b29ef6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ ### Fix - Fix error when requested WebP dimension exceeds the WebP dimension limit. - Fix path parsing in some rare cases. +- Fix HEIC/HEIF header parsing bug. ## [2.13.1] - 2020-05-06 ### Fixed diff --git a/imagemeta/heic.go b/imagemeta/heic.go index 9dc527f9..80e3f789 100644 --- a/imagemeta/heic.go +++ b/imagemeta/heic.go @@ -23,7 +23,7 @@ func (d *heicDimensionsData) IsFilled() bool { func heicReadBoxHeader(r io.Reader) (boxType string, boxDataSize int64, err error) { b := make([]byte, heicBoxHeaderSize) - _, err = r.Read(b) + _, err = io.ReadFull(r, b) if err != nil { return } @@ -36,7 +36,7 @@ func heicReadBoxHeader(r io.Reader) (boxType string, boxDataSize int64, err erro func heicReadBoxData(r io.Reader, boxDataSize int64) (b []byte, err error) { b = make([]byte, boxDataSize) - _, err = r.Read(b) + _, err = io.ReadFull(r, b) return } @@ -70,7 +70,7 @@ func heicReadMeta(d *heicDimensionsData, r io.Reader, boxDataSize int64) error { return errors.New("Invalid meta data") } - if _, err := r.Read(make([]byte, 4)); err != nil { + if _, err := io.ReadFull(r, make([]byte, 4)); err != nil { return err }