mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-14 13:21:28 +00:00
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/672>
This commit is contained in:
parent
4095a4b4c5
commit
2e507d5a4b
1 changed files with 3 additions and 5 deletions
|
@ -2717,8 +2717,7 @@ _priv_gst_value_parse_value (gchar * str,
|
||||||
if (G_UNLIKELY (!_priv_gst_value_parse_string (s, &value_end, &s, TRUE)))
|
if (G_UNLIKELY (!_priv_gst_value_parse_string (s, &value_end, &s, TRUE)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
/* Set NULL terminator for deserialization */
|
/* Set NULL terminator for deserialization */
|
||||||
c = *value_end;
|
value_s = g_strndup (value_s, value_end - value_s);
|
||||||
*value_end = '\0';
|
|
||||||
|
|
||||||
for (i = 0; i < G_N_ELEMENTS (try_types); i++) {
|
for (i = 0; i < G_N_ELEMENTS (try_types); i++) {
|
||||||
g_value_init (value, try_types[i]);
|
g_value_init (value, try_types[i]);
|
||||||
|
@ -2734,14 +2733,13 @@ _priv_gst_value_parse_value (gchar * str,
|
||||||
(type != G_TYPE_STRING))))
|
(type != G_TYPE_STRING))))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
/* Set NULL terminator for deserialization */
|
/* Set NULL terminator for deserialization */
|
||||||
c = *value_end;
|
value_s = g_strndup (value_s, value_end - value_s);
|
||||||
*value_end = '\0';
|
|
||||||
|
|
||||||
ret = gst_value_deserialize_with_pspec (value, value_s, pspec);
|
ret = gst_value_deserialize_with_pspec (value, value_s, pspec);
|
||||||
if (G_UNLIKELY (!ret))
|
if (G_UNLIKELY (!ret))
|
||||||
g_value_unset (value);
|
g_value_unset (value);
|
||||||
}
|
}
|
||||||
*value_end = c;
|
g_free (value_s);
|
||||||
}
|
}
|
||||||
|
|
||||||
*after = s;
|
*after = s;
|
||||||
|
|
Loading…
Reference in a new issue