mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-15 13:53:19 +00:00
message: Ensure that the "debug" field of error/warning/info messages is valid UTF-8
The caller might pass arbitrary data here that caused the error, and trying to set invalid UTF-8 in a GstStructure causes it to be not set at all. Later when trying to parse it, the field will not exist and the return value will point to invalid memory. Prevent this by storing NULL instead. Also print a g_warning(), the caller should never ever do this to begin with.
This commit is contained in:
parent
f8775abcae
commit
b6747e6a9d
1 changed files with 18 additions and 0 deletions
|
@ -415,6 +415,12 @@ gst_message_new_error_with_details (GstObject * src, GError * error,
|
|||
GstMessage *message;
|
||||
GstStructure *structure;
|
||||
|
||||
if (!g_utf8_validate (debug, -1, NULL)) {
|
||||
debug = NULL;
|
||||
g_warning ("Trying to set debug field of error message, but "
|
||||
"string is not valid UTF-8. Please file a bug.");
|
||||
}
|
||||
|
||||
structure = gst_structure_new_id (GST_QUARK (MESSAGE_ERROR),
|
||||
GST_QUARK (GERROR), G_TYPE_ERROR, error,
|
||||
GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
|
||||
|
@ -501,6 +507,12 @@ gst_message_new_warning_with_details (GstObject * src, GError * error,
|
|||
GstMessage *message;
|
||||
GstStructure *structure;
|
||||
|
||||
if (!g_utf8_validate (debug, -1, NULL)) {
|
||||
debug = NULL;
|
||||
g_warning ("Trying to set debug field of warning message, but "
|
||||
"string is not valid UTF-8. Please file a bug.");
|
||||
}
|
||||
|
||||
structure = gst_structure_new_id (GST_QUARK (MESSAGE_WARNING),
|
||||
GST_QUARK (GERROR), G_TYPE_ERROR, error,
|
||||
GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
|
||||
|
@ -585,6 +597,12 @@ gst_message_new_info_with_details (GstObject * src, GError * error,
|
|||
GstMessage *message;
|
||||
GstStructure *structure;
|
||||
|
||||
if (!g_utf8_validate (debug, -1, NULL)) {
|
||||
debug = NULL;
|
||||
g_warning ("Trying to set debug field of info message, but "
|
||||
"string is not valid UTF-8. Please file a bug.");
|
||||
}
|
||||
|
||||
structure = gst_structure_new_id (GST_QUARK (MESSAGE_INFO),
|
||||
GST_QUARK (GERROR), G_TYPE_ERROR, error,
|
||||
GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
|
||||
|
|
Loading…
Reference in a new issue