internal/zstd: allow stream consisting of skippable frames

For #62513
This commit is contained in:
Alexander Yastrebov 2023-09-26 23:49:23 +02:00
parent 11084a9a1e
commit 2b7ddc6c09
2 changed files with 13 additions and 1 deletions

View File

@ -169,7 +169,7 @@ retry:
// Read magic number. RFC 3.1.1.
if _, err := io.ReadFull(r.r, r.scratch[:4]); err != nil {
// We require that the stream contain at least one frame.
// We require that the stream contains at least one frame.
if err == io.EOF && !r.readOneFrame {
err = io.ErrUnexpectedEOF
}
@ -183,6 +183,7 @@ retry:
if err := r.skipFrame(); err != nil {
return err
}
r.readOneFrame = true
goto retry
}

View File

@ -95,6 +95,17 @@ var tests = []struct {
"",
"\x28\xb5\x2f\xfd\x00\x00\x15\x00\x00\x00\x00",
},
{
"single skippable frame",
"",
"\x50\x2a\x4d\x18\x00\x00\x00\x00",
},
{
"two skippable frames",
"",
"\x50\x2a\x4d\x18\x00\x00\x00\x00" +
"\x50\x2a\x4d\x18\x00\x00\x00\x00",
},
}
func TestSamples(t *testing.T) {