[File] libmagic old debian/fedora: Conditional jump or move depends on uninitialised value(s)
raf
file at raf.org
Sun Apr 26 02:22:25 EDT 2026
Hi, I have a program that uses libmagic, and I've been testing it
on all/most of the files on several real and virtual machines.
When I use valgrind, I'm seeing these errors:
Conditional jump or move depends on uninitialised value(s)
and even a memory leak when using MAGIC_COMPRESS.
Note that this is on old fedora-35 with libmagic-5.40,
and old debian-12 with libmagic-5.46.
Below is some of the valgrind output.
However, when I use the latest source for libmagic, the
uninitialised jump errors aren't there. When I tested
against the upstream versions of 5.40 and 5.46, they
also weren't there. That seems to indicate that maybe
there were patches in both the debian and fedora packages
of libmagic that introduced these errors. But that sounds
unlikely. I haven't looked into it.
I don't know what to make of this. But I thought I should let
you know. Maybe these are errors that have been fixed recently,
or maybe they were introduced by packagers. If they've been fixed
recently, that's great. But if they've been introduced by multiple
packagers, that might indicate that it would be a good idea to
include valgrind/ubsan/asan in libmagic's make test, so that
packagers are less likely to introduce a problem without
noticing it.
For something like file/libmagic that reads arbitrary input and
tries to make sense of it, the more analysis the better.
Anyway, maybe this will make more sense to you than it does to me. :-)
And maybe it doesn't matter.
cheers,
raf
fedora-35, libmagic-5.40
------------------------
/sys/power/disk
/sys/power/image_size
/sys/power/mem_sleep
/sys/power/pm_freeze_timeout
/sys/power/reserved_size
/sys/power/resume
/sys/power/state
/sys/power/wakeup_count
==356393== Conditional jump or move depends on uninitialised value(s)
==356393== at 0x49220D5: file_strncmp (softmagic.c:1940)
==356393== by 0x4928C96: magiccheck (softmagic.c:2126)
==356393== by 0x49294F4: match (softmagic.c:260)
==356393== by 0x4929B65: file_softmagic (softmagic.c:134)
==356393== by 0x493A949: file_buffer (funcs.c:445)
==356393== by 0x492373A: file_or_fd (magic.c:516)
==356393== by 0x11422C: get_what (rhcmds.c:903)
==356393== by 0x128795: json (rhdir.c:3241)
==356393== by 0x128795: visitf_format (rhdir.c:4033)
==356393== by 0x121B8D: rawhide_traverse (rhdir.c:481)
==356393== by 0x122194: rawhide_traverse (rhdir.c:600)
==356393== by 0x122194: rawhide_traverse (rhdir.c:600)
==356393== by 0x122194: rawhide_traverse (rhdir.c:600)
==356393==
==356393== Conditional jump or move depends on uninitialised value(s)
==356393== at 0x4929500: match (softmagic.c:260)
==356393== by 0x4929B65: file_softmagic (softmagic.c:134)
==356393== by 0x493A949: file_buffer (funcs.c:445)
==356393== by 0x492373A: file_or_fd (magic.c:516)
==356393== by 0x11422C: get_what (rhcmds.c:903)
==356393== by 0x128795: json (rhdir.c:3241)
==356393== by 0x128795: visitf_format (rhdir.c:4033)
==356393== by 0x121B8D: rawhide_traverse (rhdir.c:481)
==356393== by 0x122194: rawhide_traverse (rhdir.c:600)
==356393== by 0x122194: rawhide_traverse (rhdir.c:600)
==356393== by 0x122194: rawhide_traverse (rhdir.c:600)
==356393== by 0x1224FA: rawhide_search (rhdir.c:722)
==356393== by 0x10EF30: main (rh.c:1489)
==356393==
/sys/module/vt/parameters/default_red
The above two as well as this
==356393== Conditional jump or move depends on uninitialised value(s)
==356393== at 0x4929932: match (softmagic.c:374)
==356393== by 0x4929B65: file_softmagic (softmagic.c:134)
==356393== by 0x493A949: file_buffer (funcs.c:445)
==356393== by 0x492373A: file_or_fd (magic.c:516)
==356393== by 0x11422C: get_what (rhcmds.c:903)
==356393== by 0x128795: json (rhdir.c:3241)
==356393== by 0x128795: visitf_format (rhdir.c:4033)
==356393== by 0x121B8D: rawhide_traverse (rhdir.c:481)
==356393== by 0x122194: rawhide_traverse (rhdir.c:600)
==356393== by 0x122194: rawhide_traverse (rhdir.c:600)
==356393== by 0x122194: rawhide_traverse (rhdir.c:600)
==356393== by 0x122194: rawhide_traverse (rhdir.c:600)
==356393== by 0x122194: rawhide_traverse (rhdir.c:600)
==356393==
The summary at the end had (from a different run using MAGIC_COMPRESS):
==378548== HEAP SUMMARY:
==378548== in use at exit: 14,320 bytes in 2 blocks
==378548== total heap usage: 1,249,562,640 allocs, 1,249,562,638 frees, 1,127,288,196,058 bytes allocated
==378548==
==378548== 7,160 bytes in 1 blocks are definitely lost in loss record 1 of 2
==378548== at 0x484486F: malloc (vg_replace_malloc.c:381)
==378548== by 0x4B66299: inflateInit2_ (inflate.c:243)
==378548== by 0x49326C3: uncompresszlib (compress.c:576)
==378548== by 0x493296D: uncompressbuf (compress.c:826)
==378548== by 0x493AC5D: file_zmagic (compress.c:287)
==378548== by 0x493A73B: file_buffer (funcs.c:365)
==378548== by 0x492373A: file_or_fd (magic.c:516)
==378548== by 0x11422C: get_what (rhcmds.c:903)
==378548== by 0x128795: json (rhdir.c:3241)
==378548== by 0x128795: visitf_format (rhdir.c:4033)
==378548== by 0x121B8D: rawhide_traverse (rhdir.c:481)
==378548== by 0x122194: rawhide_traverse (rhdir.c:600)
==378548== by 0x122194: rawhide_traverse (rhdir.c:600)
==378548==
==378548== 7,160 bytes in 1 blocks are definitely lost in loss record 2 of 2
==378548== at 0x484486F: malloc (vg_replace_malloc.c:381)
==378548== by 0x4B66299: inflateInit2_ (inflate.c:243)
==378548== by 0x49326C3: uncompresszlib (compress.c:576)
==378548== by 0x493296D: uncompressbuf (compress.c:826)
==378548== by 0x493AC5D: file_zmagic (compress.c:287)
==378548== by 0x493A73B: file_buffer (funcs.c:365)
==378548== by 0x492373A: file_or_fd (magic.c:516)
==378548== by 0x1147FC: get_mime (rhcmds.c:961)
==378548== by 0x129C61: json (rhdir.c:3244)
==378548== by 0x129C61: visitf_format (rhdir.c:4033)
==378548== by 0x121B8D: rawhide_traverse (rhdir.c:481)
==378548== by 0x122194: rawhide_traverse (rhdir.c:600)
==378548== by 0x122194: rawhide_traverse (rhdir.c:600)
==378548==
==378548== LEAK SUMMARY:
==378548== definitely lost: 14,320 bytes in 2 blocks
==378548== indirectly lost: 0 bytes in 0 blocks
==378548== possibly lost: 0 bytes in 0 blocks
==378548== still reachable: 0 bytes in 0 blocks
==378548== suppressed: 0 bytes in 0 blocks
==378548== Use --track-origins=yes to see where uninitialised values come from
==378548== ERROR SUMMARY: 2040 errors from 5 contexts (suppressed: 0 from 0)
==378548==
==378548== 15 errors in context 1 of 5:
==378548== Conditional jump or move depends on uninitialised value(s)
==378548== at 0x4929932: match (softmagic.c:374)
==378548== by 0x4929B65: file_softmagic (softmagic.c:134)
==378548== by 0x493A949: file_buffer (funcs.c:445)
==378548== by 0x492373A: file_or_fd (magic.c:516)
==378548== by 0x1147FC: get_mime (rhcmds.c:961)
==378548== by 0x129C61: json (rhdir.c:3244)
==378548== by 0x129C61: visitf_format (rhdir.c:4033)
==378548== by 0x121B8D: rawhide_traverse (rhdir.c:481)
==378548== by 0x122194: rawhide_traverse (rhdir.c:600)
==378548== by 0x122194: rawhide_traverse (rhdir.c:600)
==378548== by 0x122194: rawhide_traverse (rhdir.c:600)
==378548== by 0x122194: rawhide_traverse (rhdir.c:600)
==378548== by 0x122194: rawhide_traverse (rhdir.c:600)
==378548==
==378548==
==378548== 1001 errors in context 2 of 5:
==378548== Conditional jump or move depends on uninitialised value(s)
==378548== at 0x49220D5: file_strncmp (softmagic.c:1940)
==378548== by 0x4928C96: magiccheck (softmagic.c:2126)
==378548== by 0x49294F4: match (softmagic.c:260)
==378548== by 0x4929B65: file_softmagic (softmagic.c:134)
==378548== by 0x493A949: file_buffer (funcs.c:445)
==378548== by 0x492373A: file_or_fd (magic.c:516)
==378548== by 0x11422C: get_what (rhcmds.c:903)
==378548== by 0x128795: json (rhdir.c:3241)
==378548== by 0x128795: visitf_format (rhdir.c:4033)
==378548== by 0x121B8D: rawhide_traverse (rhdir.c:481)
==378548== by 0x122194: rawhide_traverse (rhdir.c:600)
==378548== by 0x122194: rawhide_traverse (rhdir.c:600)
==378548== by 0x122194: rawhide_traverse (rhdir.c:600)
==378548==
==378548==
==378548== 1022 errors in context 3 of 5:
==378548== Conditional jump or move depends on uninitialised value(s)
==378548== at 0x4929500: match (softmagic.c:260)
==378548== by 0x4929B65: file_softmagic (softmagic.c:134)
==378548== by 0x493A949: file_buffer (funcs.c:445)
==378548== by 0x492373A: file_or_fd (magic.c:516)
==378548== by 0x11422C: get_what (rhcmds.c:903)
==378548== by 0x128795: json (rhdir.c:3241)
==378548== by 0x128795: visitf_format (rhdir.c:4033)
==378548== by 0x121B8D: rawhide_traverse (rhdir.c:481)
==378548== by 0x122194: rawhide_traverse (rhdir.c:600)
==378548== by 0x122194: rawhide_traverse (rhdir.c:600)
==378548== by 0x122194: rawhide_traverse (rhdir.c:600)
==378548== by 0x1224FA: rawhide_search (rhdir.c:722)
==378548== by 0x10EF30: main (rh.c:1489)
==378548==
==378548== ERROR SUMMARY: 2040 errors from 5 contexts (suppressed: 0 from 0)
debian-12, libmagic-5.46
------------------------
/sys/power/wakeup_count
/sys/power/sync_on_suspend
==3149814== Conditional jump or move depends on uninitialised value(s)
==3149814== at 0x4925E0C: ??? (in /usr/lib/x86_64-linux-gnu/libmagic.so.1.0.0)
==3149814== by 0x4927443: ??? (in /usr/lib/x86_64-linux-gnu/libmagic.so.1.0.0)
==3149814== by 0x4932269: ??? (in /usr/lib/x86_64-linux-gnu/libmagic.so.1.0.0)
==3149814== by 0x491CDEE: ??? (in /usr/lib/x86_64-linux-gnu/libmagic.so.1.0.0)
==3149814== by 0x1140EC: get_what (rhcmds.c:903)
==3149814== by 0x12527F: json (rhdir.c:3241)
==3149814== by 0x129495: visitf_format (rhdir.c:4033)
==3149814== by 0x121D96: rawhide_traverse (rhdir.c:481)
==3149814== by 0x12278A: rawhide_search (rhdir.c:722)
==3149814== by 0x10EDE8: main (rh.c:1489)
==3149814==
The summary at the end had:
==3147640== 11 errors in context 1 of 3:
==3147640== Conditional jump or move depends on uninitialised value(s)
==3147640== at 0x4925EF2: ??? (in /usr/lib/x86_64-linux-gnu/libmagic.so.1.0.0)
==3147640== by 0x4927443: ??? (in /usr/lib/x86_64-linux-gnu/libmagic.so.1.0.0)
==3147640== by 0x4932269: ??? (in /usr/lib/x86_64-linux-gnu/libmagic.so.1.0.0)
==3147640== by 0x491CDEE: ??? (in /usr/lib/x86_64-linux-gnu/libmagic.so.1.0.0)
==3147640== by 0x1140EC: get_what (rhcmds.c:903)
==3147640== by 0x12527F: json (rhdir.c:3241)
==3147640== by 0x129495: visitf_format (rhdir.c:4033)
==3147640== by 0x121D96: rawhide_traverse (rhdir.c:481)
==3147640== by 0x1223FB: rawhide_traverse (rhdir.c:600)
==3147640== by 0x1223FB: rawhide_traverse (rhdir.c:600)
==3147640== by 0x1223FB: rawhide_traverse (rhdir.c:600)
==3147640== by 0x1223FB: rawhide_traverse (rhdir.c:600)
==3147640==
==3147640==
==3147640== 1963 errors in context 2 of 3:
==3147640== Conditional jump or move depends on uninitialised value(s)
==3147640== at 0x4923125: ??? (in /usr/lib/x86_64-linux-gnu/libmagic.so.1.0.0)
==3147640== by 0x49240AE: ??? (in /usr/lib/x86_64-linux-gnu/libmagic.so.1.0.0)
==3147640== by 0x4925E00: ??? (in /usr/lib/x86_64-linux-gnu/libmagic.so.1.0.0)
==3147640== by 0x4927443: ??? (in /usr/lib/x86_64-linux-gnu/libmagic.so.1.0.0)
==3147640== by 0x4932269: ??? (in /usr/lib/x86_64-linux-gnu/libmagic.so.1.0.0)
==3147640== by 0x491CDEE: ??? (in /usr/lib/x86_64-linux-gnu/libmagic.so.1.0.0)
==3147640== by 0x1140EC: get_what (rhcmds.c:903)
==3147640== by 0x12527F: json (rhdir.c:3241)
==3147640== by 0x129495: visitf_format (rhdir.c:4033)
==3147640== by 0x121D96: rawhide_traverse (rhdir.c:481)
==3147640== by 0x1223FB: rawhide_traverse (rhdir.c:600)
==3147640== by 0x1223FB: rawhide_traverse (rhdir.c:600)
==3147640==
==3147640==
==3147640== 4452 errors in context 3 of 3:
==3147640== Conditional jump or move depends on uninitialised value(s)
==3147640== at 0x4925E0C: ??? (in /usr/lib/x86_64-linux-gnu/libmagic.so.1.0.0)
==3147640== by 0x4927443: ??? (in /usr/lib/x86_64-linux-gnu/libmagic.so.1.0.0)
==3147640== by 0x4932269: ??? (in /usr/lib/x86_64-linux-gnu/libmagic.so.1.0.0)
==3147640== by 0x491CDEE: ??? (in /usr/lib/x86_64-linux-gnu/libmagic.so.1.0.0)
==3147640== by 0x1140EC: get_what (rhcmds.c:903)
==3147640== by 0x12527F: json (rhdir.c:3241)
==3147640== by 0x129495: visitf_format (rhdir.c:4033)
==3147640== by 0x121D96: rawhide_traverse (rhdir.c:481)
==3147640== by 0x1223FB: rawhide_traverse (rhdir.c:600)
==3147640== by 0x1223FB: rawhide_traverse (rhdir.c:600)
==3147640== by 0x1223FB: rawhide_traverse (rhdir.c:600)
==3147640== by 0x12278A: rawhide_search (rhdir.c:722)
==3147640==
==3147640== ERROR SUMMARY: 6426 errors from 3 contexts (suppressed: 0 from 0)
More information about the File
mailing list