blob: 235acda8bfd2110dcbffce5d01491d1b9393593c [file] [log] [blame]
Patrick Williamsb48b7b42016-08-17 15:04:38 -05001Description: Fix buffer overflow in mp4 parsing
2Author: Ralph Giles <giles@mozilla.com>
3---
4Backport patch from debian to fix CVE-2015-0797.
5https://sources.debian.net/data/main/g/gst-plugins-bad0.10/0.10.23-7.1+deb7u2/debian/patches/buffer-overflow-mp4.patch
6
7Upstream-Status: Backport
8
9Signed-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;