From: Miguel Paris Date: Fri, 13 Dec 2019 15:06:44 +0000 (+0100) Subject: rtpbuffer: get_onebyte_header_end_offset: allow 0 offset X-Git-Tag: 1.19.3~511^2~717 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2d4d28d662bae884a8e7b8ec5b2570546bf28caa;p=platform%2Fupstream%2Fgstreamer.git rtpbuffer: get_onebyte_header_end_offset: allow 0 offset There are some cases where the full extension data could be padding. In order to make the GstRtpBuffer robust enough, this change supports this case. --- diff --git a/gst-libs/gst/rtp/gstrtpbuffer.c b/gst-libs/gst/rtp/gstrtpbuffer.c index 6a855246c5..5a4ff6f89c 100644 --- a/gst-libs/gst/rtp/gstrtpbuffer.c +++ b/gst-libs/gst/rtp/gstrtpbuffer.c @@ -1510,19 +1510,20 @@ gst_rtp_buffer_get_extension_twobytes_header (GstRTPBuffer * rtp, return FALSE; } -static guint -get_onebyte_header_end_offset (guint8 * pdata, guint wordlen) +static gboolean +get_onebyte_header_end_offset (guint8 * pdata, guint wordlen, guint *offset) { - guint offset = 0; guint bytelen = wordlen * 4; guint paddingcount = 0; - while (offset + 1 < bytelen) { + *offset = 0; + + while (*offset + 1 < bytelen) { guint8 read_id, read_len; - read_id = GST_READ_UINT8 (pdata + offset) >> 4; - read_len = (GST_READ_UINT8 (pdata + offset) & 0x0F) + 1; - offset += 1; + read_id = GST_READ_UINT8 (pdata + *offset) >> 4; + read_len = (GST_READ_UINT8 (pdata + *offset) & 0x0F) + 1; + *offset += 1; /* ID 0 means its padding, skip */ if (read_id == 0) { @@ -1534,17 +1535,21 @@ get_onebyte_header_end_offset (guint8 * pdata, guint wordlen) /* ID 15 is special and means we should stop parsing */ /* It also means we can't add an extra packet */ - if (read_id == 15) - return 0; + if (read_id == 15) { + return FALSE; + } /* Ignore extension headers where the size does not fit */ - if (offset + read_len > bytelen) - return 0; + if (*offset + read_len > bytelen) { + return FALSE; + } - offset += read_len; + *offset += read_len; } - return offset - paddingcount; + *offset -= paddingcount; + + return TRUE; } /** @@ -1586,8 +1591,7 @@ gst_rtp_buffer_add_extension_onebyte_header (GstRTPBuffer * rtp, guint8 id, if (bits != 0xBEDE) return FALSE; - offset = get_onebyte_header_end_offset (pdata, wordlen); - if (offset == 0) + if (!get_onebyte_header_end_offset (pdata, wordlen, &offset)) return FALSE; }