aacparse: Fix svace issue(DIVISION_BY_ZERO) 07/100707/7 accepted/tizen/3.0/common/20161207.194448 accepted/tizen/3.0/ivi/20161207.011901 accepted/tizen/3.0/mobile/20161207.011444 accepted/tizen/3.0/tv/20161207.011654 accepted/tizen/3.0/wearable/20161207.011752 submit/tizen_3.0/20161206.052949
authorGilbok Lee <gilbok.lee@samsung.com>
Tue, 29 Nov 2016 04:39:52 +0000 (13:39 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Wed, 30 Nov 2016 09:18:43 +0000 (18:18 +0900)
Change-Id: Iac08af5804aa15c1b65f3122028392ace2b89e64

gst/audioparsers/gstaacparse.c
packaging/gst-plugins-good.spec

index ea3e83d..8177450 100644 (file)
@@ -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;
 }
 
 
index c0802d0..3842851 100644 (file)
@@ -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/