Skip to content

libtracker-miner: Ensure basename utf8-ness in filters

Filenames with invalid UTF-8 may cause invalid writes on g_pattern_match(), as patterns like 'aa' will require the reverse of the string, and g_utf8_strreverse() might write past boundaries if the invalid UTF-8 happens near the end of the given string. See glib#1863 (closed).

Ensure the UTF-8-ness of the string by replacing those invalid characters, they presumably are irrelevant for matching purposes (as the patterns express valid UTF-8). Also reverse the string in place, so it's slightly faster at checking all the patterns.

This seems a frequent crash report in Fedora FAF along time, eg: https://retrace.fedoraproject.org/faf/reports/2559134/ https://retrace.fedoraproject.org/faf/reports/1598399/

Merge request reports