pion / rtp

A Go implementation of RTP
https://pion.ly/
MIT License
356 stars 111 forks source link

size 20 < 20: RTP header size insufficient for extension #275

Open danvirsen opened 3 months ago

danvirsen commented 3 months ago

Your environment.

The following test use a packet that was previously unmarshalled without issue:

func TestKeepAlivePacket(t *testing.T) {
    rawPkt := []byte{
        0x10, 0x64, 0x57, 0x49, 0x0, 0x0, 0x1, 0x90, 0x12, 0x34, 0xAB, 0xCD,
        0xBE, 0xDE, 0x0, 0x1, 0x2, 0xDA, 0x58, 0x43,
    }

    p := &Packet{}
    if err := p.Unmarshal(rawPkt); err != nil {
        t.Fatal(err)
    }
}

The change that causes the error was made in this commit: https://github.com/pion/rtp/commit/7dc2af56736b663e76f1400ba403532ba590bceb (v1.8.3?).

Looking at packet.go:190, the error message doesn't match the if statement. If I change the if statement to match the error message (len(buf) < extensionPayloadEnd) then everything works again.

The problem is that I'm not sure entirely sure it should work. From what I can tell, our keep-alive packet follows the specification but this is fairly new territory for me so I am less than confident. From my perspective this looks like a bug in pion/rtp, but maybe our packet is simply wrong.

What did you do?

I upgraded pion/rtp from v1.7.4 to v1.8.6 and ran our unit tests.

What did you expect?

I expected the unmarshal to work as in previous versions of the rtp package.

What happened?

The unmarshal failed with the following confusing error message:

size 20 < 20: RTP header size insufficient for extension