Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 1 | Description: Fix buffer overflow in mp4 parsing |
| 2 | Author: Ralph Giles <giles@mozilla.com> |
| 3 | --- |
| 4 | Backport patch from debian to fix CVE-2015-0797. |
| 5 | https://sources.debian.net/data/main/g/gst-plugins-bad0.10/0.10.23-7.1+deb7u2/debian/patches/buffer-overflow-mp4.patch |
| 6 | |
| 7 | Upstream-Status: Backport |
| 8 | |
| 9 | Signed-off-by: Kai Kang <kai.kang@windriver.com> |
| 10 | --- |
| 11 | --- gst-plugins-bad0.10-0.10.23.orig/gst/videoparsers/gsth264parse.c |
| 12 | +++ gst-plugins-bad0.10-0.10.23/gst/videoparsers/gsth264parse.c |
| 13 | @@ -384,6 +384,11 @@ gst_h264_parse_wrap_nal (GstH264Parse * |
| 14 | |
| 15 | GST_DEBUG_OBJECT (h264parse, "nal length %d", size); |
| 16 | |
| 17 | + if (size > G_MAXUINT32 - nl) { |
| 18 | + GST_ELEMENT_ERROR (h264parse, STREAM, FAILED, (NULL), |
| 19 | + ("overflow in nal size")); |
| 20 | + return NULL; |
| 21 | + } |
| 22 | buf = gst_buffer_new_and_alloc (size + nl + 4); |
| 23 | if (format == GST_H264_PARSE_FORMAT_AVC) { |
| 24 | GST_WRITE_UINT32_BE (GST_BUFFER_DATA (buf), size << (32 - 8 * nl)); |
| 25 | @@ -452,6 +457,11 @@ gst_h264_parse_process_nal (GstH264Parse |
| 26 | GST_DEBUG_OBJECT (h264parse, "not processing nal size %u", nalu->size); |
| 27 | return; |
| 28 | } |
| 29 | + if (G_UNLIKELY (nalu->size > 20 * 1024 * 1024)) { |
| 30 | + GST_DEBUG_OBJECT (h264parse, "not processing nal size %u (too big)", |
| 31 | + nalu->size); |
| 32 | + return; |
| 33 | + } |
| 34 | |
| 35 | /* we have a peek as well */ |
| 36 | nal_type = nalu->type; |