Update dependencies and replace uuid library (#100)
This commit is contained in:
+1
-1
@@ -98,7 +98,7 @@ func ExampleReader_Multistream() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Println("\n")
|
||||
fmt.Print("\n\n")
|
||||
|
||||
err = zr.Reset(&buf)
|
||||
if err == io.EOF {
|
||||
|
||||
+1
-1
@@ -10,11 +10,11 @@ import (
|
||||
"bufio"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"hash/crc32"
|
||||
"io"
|
||||
"time"
|
||||
|
||||
"github.com/klauspost/compress/flate"
|
||||
"github.com/klauspost/crc32"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
+34
@@ -680,3 +680,37 @@ func BenchmarkGunzipStdlib(b *testing.B) {
|
||||
}
|
||||
}
|
||||
}
|
||||
func TestTruncatedGunzip(t *testing.T) {
|
||||
in := []byte(strings.Repeat("ASDFASDFASDFASDFASDF", 1000))
|
||||
var buf bytes.Buffer
|
||||
enc := NewWriter(&buf)
|
||||
_, err := enc.Write(in)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
enc.Close()
|
||||
testdata := buf.Bytes()
|
||||
for i := 5; i < len(testdata); i += 10 {
|
||||
timer := time.NewTimer(time.Second)
|
||||
done := make(chan struct{})
|
||||
fail := make(chan struct{})
|
||||
go func() {
|
||||
r, err := NewReader(bytes.NewBuffer(testdata[:i]))
|
||||
if err == nil {
|
||||
b, err := ioutil.ReadAll(r)
|
||||
if err == nil && !bytes.Equal(testdata[:i], b) {
|
||||
close(fail)
|
||||
}
|
||||
}
|
||||
close(done)
|
||||
}()
|
||||
select {
|
||||
case <-timer.C:
|
||||
t.Fatal("Timeout decoding")
|
||||
case <-fail:
|
||||
t.Fatal("No error, but mismatch")
|
||||
case <-done:
|
||||
timer.Stop()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -7,10 +7,10 @@ package gzip
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"hash/crc32"
|
||||
"io"
|
||||
|
||||
"github.com/klauspost/compress/flate"
|
||||
"github.com/klauspost/crc32"
|
||||
)
|
||||
|
||||
// These constants are copied from the flate package, so that code that imports
|
||||
|
||||
Reference in New Issue
Block a user