[File] Problem with LESHORT casting

Greg Wildman lists at itns.co.za
Tue May 31 13:25:45 UTC 2022


Hello,

After upgrading from 5.39 to 5.40 I noticed a problem with the printing
of unsigned shorts. I can "fix" the problem by using uleshort instead
of leshort.

I created a test file with matching magic file.

echo -ne "TEST\xff\xff\x00\x80\xff\x7f^C> /tmp/test.bin

/tmp/magic
-----------
# TEST
0       string  TEST            Test File
>4      leshort x               \b, %u
>4      uleshort x              \b, %u
>6      leshort x               \b, %u
>6      uleshort x              \b, %u
>8      leshort x               \b, %u
>8      uleshort x              \b, %u


with version 5.39

[dev at defender ~]# file -m /tmp/magic /tmp/test.bin 
/tmp/test.bin: Test File, 65535, 65535, 32768, 32768, 32767, 32767

with version 5.40 and 5.41

[dev at defender ~]# file -m /tmp/magic /tmp/test.bin 
/tmp/test.bin: Test File, 4294967295, 65535, 4294934528, 32768, 32767,
32767

I think it has something to do with the following commit but that is a
guess on my part :)

  ac3a52ca05e83d6fce1f9141cee182bffb38383f
  Treat signed and unsigned types correctly when printing.



-- 
Greg


More information about the File mailing list