audio/wav: Bug fix: fmt header can be more than 16 bytes

This commit is contained in:
Hajime Hoshi 2017-01-15 22:02:59 +09:00
parent 14165cc67e
commit adde2f459e

View File

@ -147,7 +147,8 @@ chunks:
size := int64(buf[4]) | int64(buf[5])<<8 | int64(buf[6])<<16 | int64(buf[7])<<24
switch {
case bytes.Equal(buf[0:4], []byte("fmt ")):
if size != 16 {
// Size of 'fmt' header is usually 16, but can be more than 16.
if size < 16 {
return nil, fmt.Errorf("wav: invalid header: maybe non-PCM file?")
}
buf := make([]byte, size)