Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/GStreamer/gstreamer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Duponchelle <mathieu@centricular.com>2020-10-13 02:19:47 +0300
committerTim-Philipp Müller <tim@centricular.com>2020-10-14 02:59:03 +0300
commite846ef2221674aefafaaeaa67a6ad18571295b25 (patch)
tree30fc8b0f0c27e375db157be07373676a496fce51
parentfa2f853013472b4f91bee8b0fec1d95a9355d061 (diff)
gstvalue: don't write to const char *
Our various deserializing functions require NULL terminators to not over consume substrings (eg fields of an array). Instead of writing a NULL terminator to the passed-in string, which may result in segfaults, make a copy of the substring we're interested in. Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/446 Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/674>
-rw-r--r--gst/gstvalue.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/gst/gstvalue.c b/gst/gstvalue.c
index 27b22c003f..91f46b96aa 100644
--- a/gst/gstvalue.c
+++ b/gst/gstvalue.c
@@ -2577,8 +2577,7 @@ _priv_gst_value_parse_value (gchar * str,
if (G_UNLIKELY (!_priv_gst_value_parse_string (s, &value_end, &s, TRUE)))
return FALSE;
/* Set NULL terminator for deserialization */
- c = *value_end;
- *value_end = '\0';
+ value_s = g_strndup (value_s, value_end - value_s);
for (i = 0; i < G_N_ELEMENTS (try_types); i++) {
g_value_init (value, try_types[i]);
@@ -2594,14 +2593,13 @@ _priv_gst_value_parse_value (gchar * str,
(type != G_TYPE_STRING))))
return FALSE;
/* Set NULL terminator for deserialization */
- c = *value_end;
- *value_end = '\0';
+ value_s = g_strndup (value_s, value_end - value_s);
ret = gst_value_deserialize (value, value_s);
if (G_UNLIKELY (!ret))
g_value_unset (value);
}
- *value_end = c;
+ g_free (value_s);
}
*after = s;