// panic: runtime error: integer divide by zero // [signal 0x8 code=0x1 addr=0x439ae9 pc=0x439ae9] // // goroutine 1 [running]: // github.com/cryptix/wav.(*Reader).parseHeaders(0xc208032cd0, 0x0, 0x0) // /tmp/go-fuzz-build857960013/src/github.com/cryptix/wav/reader.go:200 +0xf29 // github.com/cryptix/wav.NewReader(0x7fbca32b6bd8, 0xc208037ef0, 0x2d, 0xc208032cd0, 0x0, 0x0) // /tmp/go-fuzz-build857960013/src/github.com/cryptix/wav/reader.go:64 +0x177 // github.com/cryptix/wav.Fuzz(0x7fbca3035000, 0x2d, 0x100000, 0x2) // /tmp/go-fuzz-build857960013/src/github.com/cryptix/wav/fuzz.go:12 +0x167 // github.com/dvyukov/go-fuzz/go-fuzz-dep.Main(0x570c60, 0x5d4200, 0x5f6, 0x5f6) // /home/cryptix/go/src/github.com/dvyukov/go-fuzz/go-fuzz-dep/main.go:64 +0x309 // main.main() // /tmp/go-fuzz-build857960013/src/go-fuzz-main/main.go:10 +0x4e // exit status 2 func TestReadFuzzed_panic2(t *testing.T) { t.Parallel() is := is.New(t) wavFile := strings.NewReader("RIFF%\x00\x00\x00WAVEfmt \x10\x00\x00\x00\x01\x00000000000000\a\x00data00000") _, err := NewReader(wavFile, int64(wavFile.Len())) is.Err(err) is.Equal(ErrBrokenChunkFmt, err) }
func TestSliceIDFile(t *testing.T) { is := is.New(t) id, err := asset.Identify(errorReader(true)) is.Err(err) is.Nil(id) is.Equal(err.Error(), "errorReader triggered error.") }
func TestParseHeaders_tooShort(t *testing.T) { t.Parallel() is := is.New(t) wavData := append(riff, 0x08, 0x00) wavFile := bytes.NewReader(wavData) _, err := NewReader(wavFile, int64(len(wavData))) is.Err(err) is.Equal(err, io.ErrUnexpectedEOF) }
func TestJvStringOnNonStringType(t *testing.T) { is := is.New(t) // Test that on a non-string value we get a go error, not a C assert jv := jq.JvNull() defer jv.Free() _, err := jv.String() is.Err(err) }
func TestJvFromJSONString(t *testing.T) { is := is.New(t) jv, err := jq.JvFromJSONString("[]") is.NoErr(err) is.OK(jv) is.Equal(jv.Kind(), jq.JV_KIND_ARRAY) jv, err = jq.JvFromJSONString("not valid") is.Err(err) is.Nil(jv) }
func TestParseHeaders_chunkFmtMissing(t *testing.T) { t.Parallel() is := is.New(t) var b bytes.Buffer b.Write(riff) b.Write([]byte{0x04, 0x00, 0x00, 0x00}) // chunkSize b.Write(wave) wavFile := bytes.NewReader(b.Bytes()) _, err := NewReader(wavFile, int64(b.Len())) is.Err(err) is.Equal(err, io.ErrUnexpectedEOF) }
func TestParseHeaders_corruptRiff(t *testing.T) { t.Parallel() is := is.New(t) var b bytes.Buffer b.Write([]byte{0x52, 0, 0x46, 0x46}) // "R\0FF" b.Write(chunkSize24) b.Write(wave) wavFile := bytes.NewReader(b.Bytes()) _, err := NewReader(wavFile, int64(b.Len())) is.Err(err) is.Equal(ErrNotRiff, err) }
func TestParseHeaders_notWave(t *testing.T) { t.Parallel() is := is.New(t) var b bytes.Buffer b.Write(riff) b.Write([]byte{0x09, 0x00, 0x00, 0x00}) // chunkSize b.Write([]byte{0x57, 0x42, 0x56, 0x45}) // "WBVE" b.Write(fmt20) b.Write([]byte{0}) wavFile := bytes.NewReader(b.Bytes()) _, err := NewReader(wavFile, int64(b.Len())) is.Err(err) is.Equal(ErrNotWave, err) }
func TestParseHeaders_chunkSizeNull(t *testing.T) { t.Parallel() is := is.New(t) var b bytes.Buffer b.Write(riff) b.Write([]byte{0x00, 0x00, 0x00, 0x00}) // chunkSize b.Write(wave) b.Write(fmt20) wavFile := bytes.NewReader(b.Bytes()) _, err := NewReader(wavFile, int64(b.Len())) is.Err(err) is.Equal(ErrIncorrectChunkSize{8, 16}, err) is.Equal("Incorrect ChunkSize. Got[8] Wanted[16]", err.Error()) }
func TestParseHeaders_fmtNotSupported(t *testing.T) { t.Parallel() is := is.New(t) var b bytes.Buffer b.Write(riff) b.Write(chunkSize24) b.Write(wave) b.Write(fmt20) b.Write(testRiffChunkFmt) b.Write([]byte{0x00, 0x00, 0x00, 0x00}) buf := b.Bytes() buf[21] = 2 // change byte 5 of riffChunk wavFile := bytes.NewReader(buf) _, err := NewReader(wavFile, int64(b.Len())) is.Err(err) is.Equal(ErrFormatNotSupported, err) }
func TestParseBytesID(t *testing.T) { is := is.New(t) for _, test := range []struct { In string Err string Exp string }{ { In: `c43UBJqUTjQyrcRv43pgt1UWqysgNud7a7Kohjp1Z4w1gD8LGv4p1FK48kC8ufPPRpbEtc8inVhxuFQ453GcfRFE9d`, Err: ``, Exp: "This is a pretend asset file, for testing asset id generation.\n", }, { In: `c430BJqUTjQyrcRv43pgt1UWqysgNud7a7Kohjp1Z4w1gD8LGv4p1FK48kC8ufPPRpbEtc8inVhxuFQ453GcfRFE9d`, Err: `non c4 id character at position 3`, Exp: "", }, { In: ``, Err: `c4 ids must be 90 characters long, input length 0`, Exp: "", }, { In: `c43UBJqUTjQyrcRv43pgt1UWqysgNud7a7Kohjp1Z4w1gD8LGv4p1FK48kC8ufPPRpbEtc8inVhxuFQ453GcfRFE9`, Err: `c4 ids must be 90 characters long, input length 89`, Exp: "", }, } { id, err := asset.ParseBytesID([]byte(test.In)) if len(test.Err) != 0 { is.Err(err) is.Equal(err.Error(), test.Err) } else { expectedID, err := asset.Identify(strings.NewReader(test.Exp)) is.NoErr(err) is.Equal(expectedID.Cmp(id), 0) } } }