wayland/text-input: Add some input validation to set_surrounding()
The cursor and anchor position of the surrounding text *must* be within (or right before/after) the string that is submitted as surrounding text. Everything else is a client error that we shouldn't accept and log as such. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3650>
This commit is contained in:
parent
2c42a28420
commit
423f17a982
@ -505,10 +505,18 @@ text_input_set_surrounding_text (struct wl_client *client,
|
|||||||
int32_t anchor)
|
int32_t anchor)
|
||||||
{
|
{
|
||||||
MetaWaylandTextInput *text_input = wl_resource_get_user_data (resource);
|
MetaWaylandTextInput *text_input = wl_resource_get_user_data (resource);
|
||||||
|
size_t text_len = strlen (text);
|
||||||
|
|
||||||
if (!client_matches_focus (text_input, client))
|
if (!client_matches_focus (text_input, client))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (cursor < 0 || anchor < 0 || cursor > text_len || anchor > text_len)
|
||||||
|
{
|
||||||
|
g_warning ("Client sent invalid surrounding text (text_len=%lu, cursor=%d, "
|
||||||
|
"anchor=%d), ignoring", text_len, cursor, anchor);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
g_free (text_input->pending_surrounding.text);
|
g_free (text_input->pending_surrounding.text);
|
||||||
text_input->pending_surrounding.text = g_strdup (text);
|
text_input->pending_surrounding.text = g_strdup (text);
|
||||||
text_input->pending_surrounding.cursor = cursor;
|
text_input->pending_surrounding.cursor = cursor;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user