mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-15 13:53:19 +00:00
structure: don't overread input when searching for "
When searching for the string terminator don't read past the ending 0-byte when escaping characters. Add unit test for various escaping cases.
This commit is contained in:
parent
4d7b9a91c4
commit
3b1de023fc
2 changed files with 22 additions and 2 deletions
|
@ -1928,8 +1928,11 @@ gst_structure_parse_string (gchar * s, gchar ** end, gchar ** next,
|
|||
while (*s != '"') {
|
||||
if (G_UNLIKELY (*s == 0))
|
||||
return FALSE;
|
||||
if (G_UNLIKELY (*s == '\\'))
|
||||
if (G_UNLIKELY (*s == '\\')) {
|
||||
s++;
|
||||
if (G_UNLIKELY (*s == 0))
|
||||
return FALSE;
|
||||
}
|
||||
*w = *s;
|
||||
w++;
|
||||
s++;
|
||||
|
@ -1941,8 +1944,11 @@ gst_structure_parse_string (gchar * s, gchar ** end, gchar ** next,
|
|||
while (*s != '"') {
|
||||
if (G_UNLIKELY (*s == 0))
|
||||
return FALSE;
|
||||
if (G_UNLIKELY (*s == '\\'))
|
||||
if (G_UNLIKELY (*s == '\\')) {
|
||||
s++;
|
||||
if (G_UNLIKELY (*s == 0))
|
||||
return FALSE;
|
||||
}
|
||||
s++;
|
||||
}
|
||||
s++;
|
||||
|
|
|
@ -174,6 +174,20 @@ GST_START_TEST (test_from_string)
|
|||
ASSERT_WARNING (structure = gst_structure_from_string (s, NULL));
|
||||
fail_if (structure == NULL, "Could not get structure from string %s", s);
|
||||
gst_structure_free (structure);
|
||||
|
||||
/* make sure we handle \ as last character in various things, run with valgrind */
|
||||
s = "foo,test=\"foobar\\";
|
||||
structure = gst_structure_from_string (s, NULL);
|
||||
fail_unless (structure == NULL);
|
||||
s = "\\";
|
||||
structure = gst_structure_from_string (s, NULL);
|
||||
fail_unless (structure == NULL);
|
||||
s = "foobar,test\\";
|
||||
structure = gst_structure_from_string (s, NULL);
|
||||
fail_unless (structure == NULL);
|
||||
s = "foobar,test=(string)foo\\";
|
||||
structure = gst_structure_from_string (s, NULL);
|
||||
fail_unless (structure == NULL);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
|
Loading…
Reference in a new issue