From d122ea01222f6a4ed08f2935ef6e0e06f06bfa20 Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Fri, 20 May 2011 10:34:47 +0300 Subject: [PATCH] rtp: fix static array overruns in a nicer way Use G_N_ELEMENTS instead of hard-coding the array size. --- gst/rtp/gstrtpjpegpay.c | 2 +- gst/rtp/gstrtpmp4adepay.c | 4 ++-- gst/rtp/gstrtpqcelpdepay.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gst/rtp/gstrtpjpegpay.c b/gst/rtp/gstrtpjpegpay.c index 9a34447..f223847 100644 --- a/gst/rtp/gstrtpjpegpay.c +++ b/gst/rtp/gstrtpjpegpay.c @@ -716,7 +716,7 @@ gst_rtp_jpeg_pay_handle_buffer (GstBaseRTPPayload * basepayload, guint qt; qt = info[i].qt; - if (qt > 14) + if (qt >= G_N_ELEMENTS (tables)) goto invalid_quant; qsize = tables[qt].size; diff --git a/gst/rtp/gstrtpmp4adepay.c b/gst/rtp/gstrtpmp4adepay.c index edcd8db..664864a 100644 --- a/gst/rtp/gstrtpmp4adepay.c +++ b/gst/rtp/gstrtpmp4adepay.c @@ -51,7 +51,7 @@ GST_STATIC_PAD_TEMPLATE ("sink", /* All optional parameters * * "profile-level-id=[1,MAX]" - * "config=" + * "config=" */ ) ); @@ -229,7 +229,7 @@ gst_rtp_mp4a_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps) if (!gst_bit_reader_get_bits_uint8 (&br, &sr_idx, 4)) goto bad_config; - if (sr_idx > 11 && sr_idx != 15) { + if (sr_idx >= G_N_ELEMENTS (aac_sample_rates) && sr_idx != 15) { GST_WARNING_OBJECT (depayload, "invalid sample rate index %d", sr_idx); goto bad_config; } diff --git a/gst/rtp/gstrtpqcelpdepay.c b/gst/rtp/gstrtpqcelpdepay.c index e83ed2c..ce947d4 100644 --- a/gst/rtp/gstrtpqcelpdepay.c +++ b/gst/rtp/gstrtpqcelpdepay.c @@ -164,7 +164,7 @@ static const gint frame_size[16] = { static gint get_frame_len (GstRtpQCELPDepay * depay, guint8 frame_type) { - if (frame_type > 15) + if (frame_type >= G_N_ELEMENTS (frame_size)) return 0; return frame_size[frame_type]; -- 2.7.4