Skip to content
This repository was archived by the owner on Apr 2, 2023. It is now read-only.

Commit 22bc0be

Browse files
committed
Bug fix: Crash with fuzzing data
Fixes #22
1 parent a843108 commit 22bc0be

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

fuzzing_test.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ func (b *bytesReadCloser) Close() error {
2727
return nil
2828
}
2929

30-
func TestFuzzingIssue3(t *testing.T) {
30+
func TestFuzzing(t *testing.T) {
3131
inputs := []string{
32+
// #3
3233
"\xff\xfa500000000000\xff\xff0000" +
3334
"00000000000000000000" +
3435
"00000000000000000000" +
@@ -75,6 +76,13 @@ func TestFuzzingIssue3(t *testing.T) {
7576
"\xee\u007f\xff\xff\u007f\xff\xff\u007f\xff\xff\xfc\xee\xff\xef\xbf0\xef\xbf00" +
7677
"0\xff\xee\u007f\xff\xff\u007f\xff\xff\xee\u007f\xff\xff\u007f\xff\xff\u007f\xff0\t" +
7778
"\xff\xff\xee\xee",
79+
// #22
80+
"\xff\xfa%00000000000000000" +
81+
"000000000000s0000000" +
82+
"00000000000000000000" +
83+
"00000000000000000000" +
84+
"00000000000000000000" +
85+
"00000000000000000000",
7886
}
7987
for _, input := range inputs {
8088
b := &bytesReadCloser{bytes.NewReader([]byte(input))}

internal/frame/frame.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -623,8 +623,9 @@ func (f *Frame) subbandSynthesis(gr int, ch int, out []byte) {
623623
// Setup the n_win windowing vector and the v_vec intermediate vector
624624
for ss := 0; ss < 18; ss++ { // Loop through 18 samples in 32 subbands
625625
copy(f.v_vec[ch][64:1024], f.v_vec[ch][0:1024-64])
626+
d := f.mainData.Is[gr][ch]
626627
for i := 0; i < 32; i++ { // Copy next 32 time samples to a temp vector
627-
s_vec[i] = f.mainData.Is[gr][ch][i*18+ss]
628+
s_vec[i] = d[i*18+ss]
628629
}
629630
for i := 0; i < 64; i++ { // Matrix multiply input with n_win[][] matrix
630631
sum := float32(0)

internal/maindata/huffman.go

+4
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ func readHuffman(m *bits.Bits, header frameheader.FrameHeader, sideInfo *sideinf
5959
}
6060
// Read big_values using tables according to region_x_start
6161
for is_pos := 0; is_pos < sideInfo.BigValues[gr][ch]*2; is_pos++ {
62+
// #22
63+
if is_pos >= len(mainData.Is[gr][ch]) {
64+
return fmt.Errorf("mp3: is_pos was too big: %d", is_pos)
65+
}
6266
table_num := 0
6367
if is_pos < region_1_start {
6468
table_num = sideInfo.TableSelect[gr][ch][0]

0 commit comments

Comments
 (0)