update-mime-database produces bogus suffix tree node
While debugging reproducibility issue, I found that update-mime-database
produces mime.cache
that has a suffix tree node not linked to any tree. Specifically, suffix tree starts at offset 0x1bc:
000001b0 00 00 00 01 00 00 01 38 00 00 00 00 00 00 00 06 |.......8........|
000001c0 00 00 01 c4 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000001d0 00 00 00 64 00 00 00 01 00 00 02 18 00 00 00 65 |...d...........e|
000001e0 00 00 00 01 00 00 02 24 00 00 00 66 00 00 00 02 |.......$...f....|
000001f0 00 00 02 30 00 00 00 67 00 00 00 04 00 00 02 48 |...0...g.......H|
00000200 00 00 00 6c 00 00 00 02 00 00 02 78 00 00 00 00 |...l.......x....|
00000210 00 00 00 94 00 00 00 64 00 00 00 73 00 00 00 01 |.......d...s....|
This gets 6 roots, which are:
- character 0 (so, leaf already), mime type offset=0 (?!), weight+flags=0x64
- character
d
, n_children=1, child offset 0x218 - character
e
, n_children=1, child offset 0x224 - character
f
, n_children=2, child offset 0x230 - character
g
, n_children=4, child offset 0x248 - character
l
, n_children=2, child offset 0x278
As you can see, list of root nodes ends at 0x20c, yet the first linked child is at 0x218. I'm attaching hexdump of the whole file: mime.cache.txt. The source from which it was generated is at https://github.com/QubesOS/qubes-core-agent-linux/blob/a8375d8410ca05fd3f859e46229dc906eb6cb006/misc/mime/packages/qubes-os.org.xml I used specification at https://specifications.freedesktop.org/shared-mime-info-spec/latest/ar01s02.html to decode the file.
By adding some debug prints, I found that root SuffixEntry
with character 0 (the first one on the above list) does have one child (g_list_length(entry->children) == 1
). And indeed the node at offset 0x20c is this child. Yet, since the (root) node with character 0 has no FIRST_CHILD_OFFSET
field, this child node is not linked anywhere.
My guess is this root and child node corresponds to this type in the source file (at least the weight matches):
<mime-type type="application/qubes-untrusted-file">
<comment>Untrusted file to open in a DispVM</comment>
<glob pattern="*" weight="100"/>
</mime-type>
Shouldn't this be a single (root=leaf) node, instead of a root+child? Or maybe there is something else wrong?