From 42ec5a029f8a3f7ec87b247bafd6a7548ace029a Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Tue, 6 Aug 2019 10:22:38 +1000 Subject: [PATCH] Have raczlib check the dictionary TTag --- lib/raczlib/reader.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/raczlib/reader.go b/lib/raczlib/reader.go index bc3cd13c..2a992725 100644 --- a/lib/raczlib/reader.go +++ b/lib/raczlib/reader.go @@ -316,7 +316,7 @@ func (r *Reader) nextChunk() error { dict := []byte(nil) if !chunk.CSecondary.Empty() { - if dict, err = r.loadDictionary(chunk.CSecondary); err != nil { + if dict, err = r.loadDictionary(chunk.CSecondary, chunk.TTag); err != nil { return err } } @@ -358,15 +358,15 @@ func (r *Reader) nextChunk() error { // // For a description of the RAC+Zlib secondary-data format, see // https://github.com/google/wuffs/blob/master/doc/spec/rac-spec.md#rac--zlib -func (r *Reader) loadDictionary(cRange rac.Range) ([]byte, error) { +func (r *Reader) loadDictionary(cRange rac.Range, tTag uint8) ([]byte, error) { // Load from the MRU cache, if it was loaded from the same cRange. if (cRange == r.cachedDictionaryCRange) && !cRange.Empty() { return r.cachedDictionary, nil } r.cachedDictionaryCRange = rac.Range{} - // Check the cRange size. - if (cRange.Size() < 6) || (cRange[1] > r.CompressedSize) { + // Check the cRange size and the tTag. + if (cRange.Size() < 6) || (cRange[1] > r.CompressedSize) || (tTag != 0xFF) { r.err = errInvalidDictionary return nil, r.err }