Skip to content

Commit 7458959

Browse files
authored
increased limits to comply with own tests (#78)
* fix allocation of very large blocks * increased limits for picture size and number of seekpoints * increased limits to comply with own tests; improved wording * fixed formatting
1 parent a420a1b commit 7458959

3 files changed

Lines changed: 26 additions & 26 deletions

File tree

meta/meta_test.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -261,29 +261,29 @@ func TestMissingValue(t *testing.T) {
261261
}
262262

263263
var MaliciousTooManyTags = []byte{
264-
// "fLaC"
265-
0x66, 0x4C, 0x61, 0x43,
266-
// StreamInfo header: type=0, len=34 (0x22)
267-
0x00, 0x00, 0x00, 0x22,
268-
// StreamInfo body (34 bytes):
269-
// BlockSizeMin=16, BlockSizeMax=16
270-
0x00, 0x10, 0x00, 0x10,
271-
// FrameSizeMin=0, FrameSizeMax=0
272-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
273-
// 64-bit packed: sampleRate=1, channels=1, bitsPerSample=4, nSamples=0
274-
0x00, 0x00, 0x10, 0x30, 0x00, 0x00, 0x00, 0x00,
275-
// MD5 (16 zeros)
276-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
277-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
278-
// VorbisComment header: isLast=1,type=4,len=9
279-
0x84, 0x00, 0x00, 0x09,
280-
// vendor length = 1 (little endian)
281-
0x01, 0x00, 0x00, 0x00,
282-
// vendor string: "x"
283-
0x78,
284-
// tags list length = 4278190080 (little endian)
285-
0x00, 0x00, 0x00, 0xff,
286-
}
264+
// "fLaC"
265+
0x66, 0x4C, 0x61, 0x43,
266+
// StreamInfo header: type=0, len=34 (0x22)
267+
0x00, 0x00, 0x00, 0x22,
268+
// StreamInfo body (34 bytes):
269+
// BlockSizeMin=16, BlockSizeMax=16
270+
0x00, 0x10, 0x00, 0x10,
271+
// FrameSizeMin=0, FrameSizeMax=0
272+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
273+
// 64-bit packed: sampleRate=1, channels=1, bitsPerSample=4, nSamples=0
274+
0x00, 0x00, 0x10, 0x30, 0x00, 0x00, 0x00, 0x00,
275+
// MD5 (16 zeros)
276+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
277+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
278+
// VorbisComment header: isLast=1,type=4,len=9
279+
0x84, 0x00, 0x00, 0x09,
280+
// vendor length = 1 (little endian)
281+
0x01, 0x00, 0x00, 0x00,
282+
// vendor string: "x"
283+
0x78,
284+
// tags list length = 4278190080 (little endian)
285+
0x00, 0x00, 0x00, 0xff,
286+
}
287287

288288
func TestVorbisCommentTooManyTags(t *testing.T) {
289289
_, err := flac.Parse(bytes.NewReader(MaliciousTooManyTags))

meta/seektable.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"fmt"
77
)
88

9-
const maxSeekPoints = 100000
9+
const maxSeekPoints = 1000000
1010

1111
// SeekTable contains one or more pre-calculated audio frame seek points.
1212
//

meta/vorbiscomment.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"strings"
77
)
88

9-
const maxTags = 1024
9+
const maxTags = 50000
1010

1111
// VorbisComment contains a list of name-value pairs.
1212
//
@@ -42,7 +42,7 @@ func (block *Block) parseVorbisComment() (err error) {
4242
return unexpected(err)
4343
}
4444
if x > maxTags {
45-
return fmt.Errorf("meta.Block.parseVorbisComment: %w, tags number=%d", ErrDeclaredBlockTooBig, x)
45+
return fmt.Errorf("meta.Block.parseVorbisComment: %w, number of tags=%d", ErrDeclaredBlockTooBig, x)
4646
}
4747
if x < 1 {
4848
return nil

0 commit comments

Comments
 (0)