summaryrefslogtreecommitdiffstats
path: root/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0009-ssaparse-Don-t-use-strstr-on-strings-that-are-potent.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0009-ssaparse-Don-t-use-strstr-on-strings-that-are-potent.patch')
-rw-r--r--meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0009-ssaparse-Don-t-use-strstr-on-strings-that-are-potent.patch99
1 files changed, 99 insertions, 0 deletions
diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0009-ssaparse-Don-t-use-strstr-on-strings-that-are-potent.patch b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0009-ssaparse-Don-t-use-strstr-on-strings-that-are-potent.patch
new file mode 100644
index 0000000000..e6674c7bfd
--- /dev/null
+++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-base/0009-ssaparse-Don-t-use-strstr-on-strings-that-are-potent.patch
@@ -0,0 +1,99 @@
1From 403b10eba06679319aa2e35d310236234782102f Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= <sebastian@centricular.com>
3Date: Mon, 30 Sep 2024 18:36:19 +0300
4Subject: [PATCH 2/2] ssaparse: Don't use strstr() on strings that are
5 potentially not NULL-terminated
6
7Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8036>
8
9CVE: CVE-2024-47541
10Upstream-Status: Backport [https://gitlab.freedesktop.org/gstreamer/gstreamer/-/commit/403b10eba06679319aa2e35d310236234782102f]
11Signed-off-by: Peter Marko <peter.marko@siemens.com>
12---
13 gst/subparse/gstssaparse.c | 36 +++++++++++++++++++++++++++++++++++-
14 meson.build | 1 +
15 2 files changed, 36 insertions(+), 1 deletion(-)
16
17diff --git a/gst/subparse/gstssaparse.c b/gst/subparse/gstssaparse.c
18index 37b892e928..c162a542f5 100644
19--- a/gst/subparse/gstssaparse.c
20+++ b/gst/subparse/gstssaparse.c
21@@ -146,6 +146,35 @@ gst_ssa_parse_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
22 return res;
23 }
24
25+#ifndef HAVE_MEMMEM
26+// memmem() is a GNU extension so if it's not available we'll need
27+// our own implementation here. Thanks C.
28+static void *
29+my_memmem (const void *haystack, size_t haystacklen, const void *needle,
30+ size_t needlelen)
31+{
32+ const guint8 *cur, *end;
33+
34+ if (needlelen > haystacklen)
35+ return NULL;
36+ if (needlelen == 0)
37+ return (void *) haystack;
38+
39+
40+ cur = haystack;
41+ end = cur + haystacklen - needlelen;
42+
43+ for (; cur <= end; cur++) {
44+ if (memcmp (cur, needle, needlelen) == 0)
45+ return (void *) cur;
46+ }
47+
48+ return NULL;
49+}
50+#else
51+#define my_memmem memmem
52+#endif
53+
54 static gboolean
55 gst_ssa_parse_setcaps (GstPad * sinkpad, GstCaps * caps)
56 {
57@@ -154,6 +183,7 @@ gst_ssa_parse_setcaps (GstPad * sinkpad, GstCaps * caps)
58 const GValue *val;
59 GstStructure *s;
60 const guchar bom_utf8[] = { 0xEF, 0xBB, 0xBF };
61+ const guint8 header[] = "[Script Info]";
62 const gchar *end;
63 GstBuffer *priv;
64 GstMapInfo map;
65@@ -193,7 +223,7 @@ gst_ssa_parse_setcaps (GstPad * sinkpad, GstCaps * caps)
66 left -= 3;
67 }
68
69- if (!strstr (ptr, "[Script Info]"))
70+ if (!my_memmem (ptr, left, header, sizeof (header) - 1))
71 goto invalid_init;
72
73 if (!g_utf8_validate (ptr, left, &end)) {
74@@ -231,6 +261,10 @@ invalid_init:
75 }
76 }
77
78+#ifdef my_memmem
79+#undef my_memmem
80+#endif
81+
82 static gboolean
83 gst_ssa_parse_remove_override_codes (GstSsaParse * parse, gchar * txt)
84 {
85diff --git a/meson.build b/meson.build
86index d1033bef4a..65d0944114 100644
87--- a/meson.build
88+++ b/meson.build
89@@ -199,6 +199,7 @@ check_functions = [
90 ['HAVE_LRINTF', 'lrintf', '#include<math.h>'],
91 ['HAVE_MMAP', 'mmap', '#include<sys/mman.h>'],
92 ['HAVE_LOG2', 'log2', '#include<math.h>'],
93+ ['HAVE_MEMMEM', 'memmem', '#include<string.h>'],
94 ]
95
96 libm = cc.find_library('m', required : false)
97--
982.30.2
99