From 1248320402e89b12def4352fd36df268ceead5c6 Mon Sep 17 00:00:00 2001 From: Steve van Loben Sels Date: Tue, 23 Jul 2019 13:07:52 -0700 Subject: [PATCH] More aggressive resets of state in xerial reader (#322) In cases where the xerial reader requires more bytes than available in the decompressed buffer, we currently get corrupt data. That would result in the reader halting. Clearing out x.output and x.header ensures that this condition is handled gracefully. --- snappy/xerial.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/snappy/xerial.go b/snappy/xerial.go index 23d523ccf..06b73909e 100644 --- a/snappy/xerial.go +++ b/snappy/xerial.go @@ -27,6 +27,7 @@ func (x *xerialReader) Reset(r io.Reader) { x.reader = r x.input = x.input[:0] x.output = x.output[:0] + x.header = [16]byte{} x.offset = 0 x.nbytes = 0 } @@ -72,6 +73,7 @@ func (x *xerialReader) WriteTo(w io.Writer) (int64, error) { } func (x *xerialReader) readChunk(dst []byte) (int, error) { + x.output = x.output[:0] x.offset = 0 prefix := 0