Skip to content

Commit

Permalink
Validate CCFRB num_reports more strictly
Browse files Browse the repository at this point in the history
  • Loading branch information
tanghaowillow authored and stv0g committed Aug 9, 2023
1 parent fa207d7 commit 4160a9f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion rfc8888.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"encoding/binary"
"errors"
"fmt"
"math"
)

// https://www.rfc-editor.org/rfc/rfc8888.html#name-rtcp-congestion-control-fee
Expand Down Expand Up @@ -256,10 +257,15 @@ func (b *CCFeedbackReportBlock) unmarshal(rawPacket []byte) error {
if numReportsField == 0 {
return nil
}

if int(b.BeginSequence)+int(numReportsField) > math.MaxUint16 {
return errIncorrectNumReports
}

endSequence := b.BeginSequence + numReportsField
numReports := endSequence - b.BeginSequence + 1

if len(rawPacket) < int(reportsOffset+numReports*2) {
if len(rawPacket) < reportsOffset+int(numReports)*2 {
return errIncorrectNumReports
}
b.MetricBlocks = make([]CCFeedbackMetricBlock, numReports)
Expand Down

0 comments on commit 4160a9f

Please sign in to comment.