[File] Resend: byte %02X formatted as %..X instead of %..hhX => CF turns into FFFFFFCF &c.

наб nabijaczleweli at nabijaczleweli.xyz
Wed Jan 8 11:59:35 UTC 2025


Hi!

Attaching zfs send, currently identified as
  snd: ZFS snapshot (little-endian machine), version 50855953, type: ZFS, destination GUID: 02 FFFFFF90 FFFFFF8D FFFFFF9F FFFFFFE6 FFFFFFCF 7E FFFFFFC0, source GUID: FFFFFF94 FFFFFF88 78 14 FFFFFF99 FFFFFFBB FFFFFFCA FFFFFFCF, name: 'tarta-zoot/var/local at debian-12.8'
which corresponds to
  >40	byte	x	destination GUID: %02X
  >41	byte	x	%02X
in the magic file.

The GUID is actually ...9f 8d 90 02 (as expected):
  $ hd snd | grep -i '9f 8d 90 02'
  000020 02 00 00 00 0c 00 00 00 c0 7e cf e6 9f 8d 90 02  >.........~.柍*..<
so this is a formatting error on libmagic's side
(presumably promoting a signed byte to a signed int);

I tried turning those into %02hhX but got hit with a "not valid" error
due to apprentice.c's
		/*
		 * Don't accept h and hh modifiers. They make writing
		 * magic entries more complicated, for very little benefit
		 */
so whatever code's formatting this should feed the right-sized types to sprintf(),
much like apprentice.c already identifies earlier in that function.
I haven't managed to identify where that happens.

Best,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: snd
Type: application/octet-stream
Size: 5480 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20250108/3f4085e8/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20250108/3f4085e8/attachment.asc>


More information about the File mailing list