Skip to content

Commit 4160a9f

Browse files
tanghaowillowstv0g
authored andcommittedAug 9, 2023
Validate CCFRB num_reports more strictly
1 parent fa207d7 commit 4160a9f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed
 

Diff for: ‎rfc8888.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"encoding/binary"
88
"errors"
99
"fmt"
10+
"math"
1011
)
1112

1213
// https://www.rfc-editor.org/rfc/rfc8888.html#name-rtcp-congestion-control-fee
@@ -256,10 +257,15 @@ func (b *CCFeedbackReportBlock) unmarshal(rawPacket []byte) error {
256257
if numReportsField == 0 {
257258
return nil
258259
}
260+
261+
if int(b.BeginSequence)+int(numReportsField) > math.MaxUint16 {
262+
return errIncorrectNumReports
263+
}
264+
259265
endSequence := b.BeginSequence + numReportsField
260266
numReports := endSequence - b.BeginSequence + 1
261267

262-
if len(rawPacket) < int(reportsOffset+numReports*2) {
268+
if len(rawPacket) < reportsOffset+int(numReports)*2 {
263269
return errIncorrectNumReports
264270
}
265271
b.MetricBlocks = make([]CCFeedbackMetricBlock, numReports)

0 commit comments

Comments
 (0)
Please sign in to comment.