Skip to content

RTP Packet Reader Padding Bug #140

@brandon-hc

Description

@brandon-hc

When calculating the payload size on Line 153 of rtp_packet_reader.go, it is subtracting the padding size.
The padding size value is set on Line 44 in rtp_parse.go when p.Header.Padding is set, which all seems correct.

However, due to the rtp.Packet being reused PaddingSize remains set with the previous padding value., causing future RTP payloads to be truncated.

  1. rtpUnmarshalPayload receives an RTP packet with Padding set in header, sets the PaddingSize property on rtp.Packet correctly.
  2. Read correctly calculates payloadSize, subtracting the PaddingSize from Step 1.
  3. rtpUnmarshalPayload receives an RTP packet without Padding set in header, the PaddingSize property remains unchanged from Step 1.
  4. Read incorrectly calculates payloadSize, using the old PaddingSize from Step 1.

I was able to resolve it by either adding an else condition in rtpUnmarshalPayload to set PaddingSize to 0 or checking Header.Padding flag before substracting in Read.

This may not have come up before as I made some changes to the library to add support reading video from the caller, not sure if PCMU/PCMA RTP packets ever use the Padding flag. If there is interest in officially adding video support to the library, I could create a Discussion thread to discuss further.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions