xdgmime: Prevent infinite loops from badly-formed MIME registrations

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1875
This commit is contained in:
Philip Withnall 2019-09-02 18:02:05 +01:00 committed by Emmanuel Fleury
parent fa6f45536d
commit 38869ece24

View File

@ -966,7 +966,9 @@ _xdg_mime_cache_mime_type_subclass (const char *mime,
for (j = 0; j < n_parents; j++)
{
parent_offset = GET_UINT32 (cache->buffer, offset + 4 + 4 * j);
if (_xdg_mime_cache_mime_type_subclass (cache->buffer + parent_offset, ubase))
if (strcmp (cache->buffer + parent_offset, mime) != 0 &&
strcmp (cache->buffer + parent_offset, umime) != 0 &&
_xdg_mime_cache_mime_type_subclass (cache->buffer + parent_offset, ubase))
return 1;
}