discoverer: Misidentifies some image files files as MPEG, leading to high CPU usage and system lockups
The .dds (DirectDraw Surface) file format is handled badly by GstDiscoverer.
To reproduce, you can try this program:
import gi
gi.require_version('Gst', '1.0')
gi.require_version('GstPbutils', '1.0')
from gi.repository import Gst, GstPbutils
import pathlib
import sys
Gst.init(sys.argv)
discoverer = GstPbutils.Discoverer.new(5 * Gst.SECOND)
path = pathlib.Path(sys.argv[1])
print('Reading: {}'.format(path))
result = discoverer.discover_uri(path.absolute().as_uri())
print(result)
Run it against this .dds file:WTF.dds.
At best you'll see the format detection taking a very long time, and giving an incorrect result. At worst, at least on my Fedora 30 machine, this triggers some bug in Linux that causes the whole system to hang.
This has been causing problems in conjunction with the Tracker indexer, as Tracker may scan a directory full of .dds files with unfortunate results. We can avoid this in Tracker by blocklisting .dds files, and perhaps reducing the timeout that we pass to gst_discoverer_new()
but it would be nice to also fix GstDiscoverer if that's possible!
Since reporting this issue, it's been reproduced using image/ktx
and image/x-tga
files too.