summaryrefslogtreecommitdiff
path: root/gst-libs/gst/rtp
diff options
context:
space:
mode:
authorStian Selnes <stian@pexip.com>2015-07-02 20:50:00 +0200
committerSebastian Dröge <sebastian@centricular.com>2015-07-06 12:06:47 +0300
commit1586981b1bf88016ae2e39bde18e111306fbf7f2 (patch)
tree987b175ebad8341a6e9896052bd53a7a1cb623be /gst-libs/gst/rtp
parent008a2288652fdf25baa5af993b4ac76b0634a7ad (diff)
rtcpbuffer: Fix validation of packets with padding
The padding (if any) is included in the length of the last packet, see RFC 3550. Section 6.4.1: padding (P): 1 bit If the padding bit is set, this individual RTCP packet contains some additional padding octets at the end which are not part of the control information but are included in the length field. The last octet of the padding is a count of how many padding octets should be ignored, including itself (it will be a multiple of four). Section A.2: * The padding bit (P) should be zero for the first packet of a compound RTCP packet because padding should only be applied, if it is needed, to the last packet. * The length fields of the individual RTCP packets must add up to the overall length of the compound RTCP packet as received. https://bugzilla.gnome.org/show_bug.cgi?id=751883
Diffstat (limited to 'gst-libs/gst/rtp')
-rw-r--r--gst-libs/gst/rtp/gstrtcpbuffer.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/gst-libs/gst/rtp/gstrtcpbuffer.c b/gst-libs/gst/rtp/gstrtcpbuffer.c
index 7d6b541c0..e5e4ca7af 100644
--- a/gst-libs/gst/rtp/gstrtcpbuffer.c
+++ b/gst-libs/gst/rtp/gstrtcpbuffer.c
@@ -129,24 +129,28 @@ gst_rtcp_buffer_validate_data_internal (guint8 * data, guint len,
if (data_len < 4)
break;
+ /* padding only allowed on last packet */
+ if (padding)
+ break;
+
/* check version of new packet */
version = data[0] & 0xc0;
if (version != (GST_RTCP_VERSION << 6))
goto wrong_version;
- /* padding only allowed on last packet */
- if ((padding = data[0] & 0x20))
- break;
+ /* check padding of new packet */
+ if (data[0] & 0x20) {
+ padding = TRUE;
+ /* last byte of padding contains the number of padded bytes including
+ * itself. must be a multiple of 4, but cannot be 0. */
+ pad_bytes = data[data_len - 1];
+ if (pad_bytes == 0 || (pad_bytes & 0x3))
+ goto wrong_padding;
+ }
}
- if (data_len > 0) {
- /* some leftover bytes, check padding */
- if (!padding)
- goto wrong_length;
-
- /* get padding */
- pad_bytes = data[data_len - 1];
- if (data_len != pad_bytes)
- goto wrong_padding;
+ if (data_len != 0) {
+ /* some leftover bytes */
+ goto wrong_length;
}
return TRUE;