From 94a4cefd3dda33922f962c7ff483e89df35be920 Mon Sep 17 00:00:00 2001 From: Gilbok Lee Date: Tue, 29 Nov 2016 13:39:52 +0900 Subject: [PATCH 1/1] aacparse: Fix svace issue(DIVISION_BY_ZERO) Change-Id: Iac08af5804aa15c1b65f3122028392ace2b89e64 --- gst/audioparsers/gstaacparse.c | 29 +++++++++++++++++++---------- packaging/gst-plugins-good.spec | 2 +- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/gst/audioparsers/gstaacparse.c b/gst/audioparsers/gstaacparse.c index ea3e83d..8177450 100644 --- a/gst/audioparsers/gstaacparse.c +++ b/gst/audioparsers/gstaacparse.c @@ -1684,6 +1684,7 @@ int get_aac_parse_get_adts_frame_length (const unsigned char* data, static gboolean gst_aac_parse_estimate_duration (GstBaseParse * parse) { + gboolean ret = FALSE; GstFlowReturn res = GST_FLOW_OK; gint64 pull_size = 0, file_size = 0, offset = 0, num_frames=0, duration=0; guint profile = 0, sample_rate_index = 0, sample_rate = 0, channel = 0; @@ -1726,8 +1727,7 @@ gst_aac_parse_estimate_duration (GstBaseParse * parse) gst_buffer_map(buffer, &map, GST_MAP_READ); buf = map.data; buffer_size = map.size; - if(buffer_size != pull_size) - { + if (buffer_size != pull_size) { GST_ERROR_OBJECT(aacparse, "We got different buffer_size(%d) with pull_size(%d).", buffer_size, pull_size); } @@ -1739,9 +1739,8 @@ gst_aac_parse_estimate_duration (GstBaseParse * parse) sample_rate_index = (buf[i+2] >> 2) & 0xf; sample_rate = gst_aac_parse_get_sample_rate_from_index(sample_rate_index); if (sample_rate == 0) { - gst_buffer_unmap(buffer, &map); GST_WARNING_OBJECT (aacparse, "Invalid sample rate index (0)"); - return FALSE; + goto EXIT; } channel = (buf[i+2] & 0x1) << 2 | (buf[i+3] >> 6); @@ -1758,10 +1757,9 @@ gst_aac_parse_estimate_duration (GstBaseParse * parse) } else if (frame_size == -1) { offset++; lost_sync_count++; // lost sync count limmitation 2K Bytes - if (lost_sync_count > (1024*2)) - { - gst_buffer_unmap(buffer, &map); - return FALSE; + if (lost_sync_count > (1024*2)) { + GST_WARNING_OBJECT (aacparse, "lost_sync_count is larger than 2048"); + goto EXIT; } } else { offset += frame_size; @@ -1794,7 +1792,16 @@ gst_aac_parse_estimate_duration (GstBaseParse * parse) frame_duration_us = (1024 * 1000000ll + (sample_rate - 1)) / sample_rate; duration = num_frames * frame_duration_us; + if (duration == 0) { + GST_WARNING_OBJECT (aacparse, "Invalid duration"); + goto EXIT; + } estimated_bitrate = (gint)((gfloat)(offset * 8) / (gfloat)(duration / 1000)); + + if (estimated_bitrate == 0) { + GST_WARNING_OBJECT (aacparse, "Invalid estimated_bitrate"); + goto EXIT; + } estimated_duration = (GstClockTime)((file_size * 8) / (estimated_bitrate * 1000)) * GST_SECOND; GST_INFO_OBJECT (aacparse, "number of frame = %"G_GINT64_FORMAT, num_frames); @@ -1811,10 +1818,12 @@ gst_aac_parse_estimate_duration (GstBaseParse * parse) break; } } + ret = TRUE; +EXIT: gst_buffer_unmap(buffer, &map); - gst_buffer_unref (buffer); - return TRUE; + gst_buffer_unref(buffer); + return ret; } diff --git a/packaging/gst-plugins-good.spec b/packaging/gst-plugins-good.spec index c0802d0..3842851 100644 --- a/packaging/gst-plugins-good.spec +++ b/packaging/gst-plugins-good.spec @@ -3,7 +3,7 @@ Name: gst-plugins-good Version: 1.6.1 -Release: 14 +Release: 15 License: LGPL-2.1+ Summary: GStreamer Streaming-Media Framework Plug-Ins Url: http://gstreamer.freedesktop.org/ -- 2.7.4