Skip to content

Commit

Permalink
Fix empty twcc packet unmarshalling
Browse files Browse the repository at this point in the history
Currently empty twcc packets fail unmarshalling because they are too
short. These packets aren't actually invalid, however.
  • Loading branch information
kevmo314 authored and Sean-Der committed Nov 19, 2021
1 parent 5804f5f commit a4508c4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Gabor Pongracz <gabor.pongracz@proemergotech.com>
Hugo Arregui <hugo.arregui@gmail.com>
Hugo Arregui <hugo@decentraland.org>
Juliusz Chroboczek <jch@irif.fr>
Kevin Wang <kevmo314@gmail.com>
lllf <littlelightlittlefire@gmail.com>
Luke Curley <kixelated@gmail.com>
Max Hawkins <maxhawkins@gmail.com>
Expand Down
2 changes: 1 addition & 1 deletion transport_layer_cc.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ func (t *TransportLayerCC) Unmarshal(rawPacket []byte) error { //nolint:gocognit
// header's length + payload's length
totalLength := 4 * (t.Header.Length + 1)

if totalLength <= headerLength+packetChunkOffset {
if totalLength < headerLength+packetChunkOffset {
return errPacketTooShort
}

Expand Down
25 changes: 25 additions & 0 deletions transport_layer_cc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,31 @@ func TestTransportLayerCC_Unmarshal(t *testing.T) {
},
WantError: nil,
},
{
Name: "example3",
Data: []byte{
0x8f, 0xcd, 0x0, 0x4,
0x9a, 0xcb, 0x4, 0x42,
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0,
},
Want: TransportLayerCC{
Header: Header{
Padding: false,
Count: FormatTCC,
Type: TypeTransportSpecificFeedback,
Length: 4,
},
SenderSSRC: 2596996162,
MediaSSRC: 0,
BaseSequenceNumber: 0,
PacketStatusCount: 0,
ReferenceTime: 0,
FbPktCount: 0,
},
WantError: nil,
},
} {
test := test
t.Run(test.Name, func(t *testing.T) {
Expand Down

0 comments on commit a4508c4

Please sign in to comment.