Skip to content

Commit a4508c4

Browse files
kevmo314Sean-Der
authored andcommitted
Fix empty twcc packet unmarshalling
Currently empty twcc packets fail unmarshalling because they are too short. These packets aren't actually invalid, however.
1 parent 5804f5f commit a4508c4

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

AUTHORS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Gabor Pongracz <gabor.pongracz@proemergotech.com>
1212
Hugo Arregui <hugo.arregui@gmail.com>
1313
Hugo Arregui <hugo@decentraland.org>
1414
Juliusz Chroboczek <jch@irif.fr>
15+
Kevin Wang <kevmo314@gmail.com>
1516
lllf <littlelightlittlefire@gmail.com>
1617
Luke Curley <kixelated@gmail.com>
1718
Max Hawkins <maxhawkins@gmail.com>

transport_layer_cc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ func (t *TransportLayerCC) Unmarshal(rawPacket []byte) error { //nolint:gocognit
447447
// header's length + payload's length
448448
totalLength := 4 * (t.Header.Length + 1)
449449

450-
if totalLength <= headerLength+packetChunkOffset {
450+
if totalLength < headerLength+packetChunkOffset {
451451
return errPacketTooShort
452452
}
453453

transport_layer_cc_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,31 @@ func TestTransportLayerCC_Unmarshal(t *testing.T) {
630630
},
631631
WantError: nil,
632632
},
633+
{
634+
Name: "example3",
635+
Data: []byte{
636+
0x8f, 0xcd, 0x0, 0x4,
637+
0x9a, 0xcb, 0x4, 0x42,
638+
0x0, 0x0, 0x0, 0x0,
639+
0x0, 0x0, 0x0, 0x0,
640+
0x0, 0x0, 0x0, 0x0,
641+
},
642+
Want: TransportLayerCC{
643+
Header: Header{
644+
Padding: false,
645+
Count: FormatTCC,
646+
Type: TypeTransportSpecificFeedback,
647+
Length: 4,
648+
},
649+
SenderSSRC: 2596996162,
650+
MediaSSRC: 0,
651+
BaseSequenceNumber: 0,
652+
PacketStatusCount: 0,
653+
ReferenceTime: 0,
654+
FbPktCount: 0,
655+
},
656+
WantError: nil,
657+
},
633658
} {
634659
test := test
635660
t.Run(test.Name, func(t *testing.T) {

0 commit comments

Comments
 (0)