From 44b18ea2b6f3d30683affa4d4cac2c1616f5a31b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sun, 30 Dec 2018 17:26:04 +0000 Subject: [PATCH 1/2] rtcpbuffer: fix function guards with side effects Code in g_return_*() must not have side effects, as it might be compiled out if -DG_DISABLE_CHECKS is used, in which case we would read garbage off the stack. --- gst-libs/gst/rtp/gstrtcpbuffer.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gst-libs/gst/rtp/gstrtcpbuffer.c b/gst-libs/gst/rtp/gstrtcpbuffer.c index 25201d698..eff0f00e4 100644 --- a/gst-libs/gst/rtp/gstrtcpbuffer.c +++ b/gst-libs/gst/rtp/gstrtcpbuffer.c @@ -2822,8 +2822,9 @@ gst_rtcp_packet_xr_get_rle_nth_chunk (GstRTCPPacket * packet, guint32 chunk_count; guint8 *data; - g_return_val_if_fail (gst_rtcp_packet_xr_get_rle_info (packet, NULL, NULL, - NULL, NULL, &chunk_count), FALSE); + if (!gst_rtcp_packet_xr_get_rle_info (packet, NULL, NULL, NULL, NULL, + &chunk_count)) + g_return_val_if_reached (FALSE); if (nth >= chunk_count) return FALSE; @@ -2917,8 +2918,9 @@ gst_rtcp_packet_xr_get_prt_by_seq (GstRTCPPacket * packet, guint16 begin_seq, end_seq; guint8 *data; - g_return_val_if_fail (gst_rtcp_packet_xr_get_prt_info (packet, NULL, NULL, - &begin_seq, &end_seq), FALSE); + if (!gst_rtcp_packet_xr_get_prt_info (packet, NULL, NULL, &begin_seq, + &end_seq)) + g_return_val_if_reached (FALSE); if (seq >= end_seq || seq < begin_seq) return FALSE; -- GitLab From 83806dc4e1650190c46a90a3a439996a6406fa93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sun, 30 Dec 2018 18:05:18 +0000 Subject: [PATCH 2/2] rtcpbuffer: fix typo --- gst-libs/gst/rtp/gstrtcpbuffer.c | 16 ++++++++-------- gst-libs/gst/rtp/gstrtcpbuffer.h | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gst-libs/gst/rtp/gstrtcpbuffer.c b/gst-libs/gst/rtp/gstrtcpbuffer.c index eff0f00e4..d47caa9e2 100644 --- a/gst-libs/gst/rtp/gstrtcpbuffer.c +++ b/gst-libs/gst/rtp/gstrtcpbuffer.c @@ -2749,7 +2749,7 @@ gst_rtcp_packet_xr_get_block_length (GstRTCPPacket * packet) * gst_rtcp_packet_xr_get_rle_info: * @packet: a valid XR #GstRTCPPacket which is Loss RLE or Duplicate RLE report. * @ssrc: the SSRC of the RTP data packet source being reported upon by this report block. - * @thining: the amount of thinning performed on the sequence number space. + * @thinning: the amount of thinning performed on the sequence number space. * @begin_seq: the first sequence number that this block reports on. * @end_seq: the last sequence number that this block reports on plus one. * @chunk_count: the number of chunks calculated by block length. @@ -2762,7 +2762,7 @@ gst_rtcp_packet_xr_get_block_length (GstRTCPPacket * packet) */ gboolean gst_rtcp_packet_xr_get_rle_info (GstRTCPPacket * packet, guint32 * ssrc, - guint8 * thining, guint16 * begin_seq, guint16 * end_seq, + guint8 * thinning, guint16 * begin_seq, guint16 * end_seq, guint32 * chunk_count) { guint8 *data; @@ -2784,8 +2784,8 @@ gst_rtcp_packet_xr_get_rle_info (GstRTCPPacket * packet, guint32 * ssrc, /* skip header + current item offset */ data += packet->offset + packet->item_offset; - if (thining) - *thining = data[1] & 0x0f; + if (thinning) + *thinning = data[1] & 0x0f; /* go to ssrc */ data += 4; @@ -2848,7 +2848,7 @@ gst_rtcp_packet_xr_get_rle_nth_chunk (GstRTCPPacket * packet, * gst_rtcp_packet_xr_get_prt_info: * @packet: a valid XR #GstRTCPPacket which has a Packet Receipt Times Report Block * @ssrc: the SSRC of the RTP data packet source being reported upon by this report block. - * @thining: the amount of thinning performed on the sequence number space. + * @thinning: the amount of thinning performed on the sequence number space. * @begin_seq: the first sequence number that this block reports on. * @end_seq: the last sequence number that this block reports on plus one. * @@ -2860,7 +2860,7 @@ gst_rtcp_packet_xr_get_rle_nth_chunk (GstRTCPPacket * packet, */ gboolean gst_rtcp_packet_xr_get_prt_info (GstRTCPPacket * packet, - guint32 * ssrc, guint8 * thining, guint16 * begin_seq, guint16 * end_seq) + guint32 * ssrc, guint8 * thinning, guint16 * begin_seq, guint16 * end_seq) { guint8 *data; guint16 block_len; @@ -2876,8 +2876,8 @@ gst_rtcp_packet_xr_get_prt_info (GstRTCPPacket * packet, /* skip header + current item offset */ data += packet->offset + packet->item_offset; - if (thining) - *thining = data[1] & 0x0f; + if (thinning) + *thinning = data[1] & 0x0f; /* go to ssrc */ data += 4; diff --git a/gst-libs/gst/rtp/gstrtcpbuffer.h b/gst-libs/gst/rtp/gstrtcpbuffer.h index 8b49d8a04..fe094999a 100644 --- a/gst-libs/gst/rtp/gstrtcpbuffer.h +++ b/gst-libs/gst/rtp/gstrtcpbuffer.h @@ -526,7 +526,7 @@ guint16 gst_rtcp_packet_xr_get_block_length (GstRTCPPacket * packet); GST_RTP_API gboolean gst_rtcp_packet_xr_get_rle_info (GstRTCPPacket * packet, - guint32 * ssrc, guint8 * thining, + guint32 * ssrc, guint8 * thinning, guint16 * begin_seq, guint16 * end_seq, guint32 * chunk_count); @@ -536,7 +536,7 @@ gboolean gst_rtcp_packet_xr_get_rle_nth_chunk (GstRTCPPacket * packet, g GST_RTP_API gboolean gst_rtcp_packet_xr_get_prt_info (GstRTCPPacket * packet, - guint32 * ssrc, guint8 * thining, + guint32 * ssrc, guint8 * thinning, guint16 * begin_seq, guint16 * end_seq); GST_RTP_API -- GitLab