prevent decoding formats with zero clock rate or channels (#770)

This commit is contained in:
Alessandro Ros
2025-05-01 17:06:55 +02:00
committed by GitHub
parent 18307140ec
commit bfacd10d35
16 changed files with 76 additions and 30 deletions

View File

@@ -1,6 +1,7 @@
package format
import (
"fmt"
"strconv"
"strings"
@@ -23,15 +24,15 @@ func (f *AC3) unmarshal(ctx *unmarshalContext) error {
tmp := strings.SplitN(ctx.clock, "/", 2)
tmp1, err := strconv.ParseUint(tmp[0], 10, 31)
if err != nil {
return err
if err != nil || tmp1 == 0 {
return fmt.Errorf("invalid sample rate: '%s'", tmp[0])
}
f.SampleRate = int(tmp1)
if len(tmp) >= 2 {
tmp1, err := strconv.ParseUint(tmp[1], 10, 31)
if err != nil {
return err
if err != nil || tmp1 == 0 {
return fmt.Errorf("invalid channel count: '%s'", tmp[1])
}
f.ChannelCount = int(tmp1)
} else {