gbookmarkfile: check length before dereferencing groups

There is no requirement that groups is NULL terminated, so we should check
that the bounds are within the specified length before checking for a
NULL terminating value.

https://bugzilla.gnome.org/show_bug.cgi?id=792351
This commit is contained in:
Christian Hergert 2018-01-08 22:13:03 -08:00
parent 181d1c3052
commit 17e03effda

View File

@ -2862,7 +2862,7 @@ g_bookmark_file_set_groups (GBookmarkFile *bookmark,
if (groups)
{
for (i = 0; groups[i] != NULL && i < length; i++)
for (i = 0; i < length && groups[i] != NULL; i++)
item->metadata->groups = g_list_append (item->metadata->groups,
g_strdup (groups[i]));
}