#1041041 file: superflous 0 prepended to serial number in ntfs filesystem detection

Package:
file
Source:
file
Description:
Recognize the type of data in a file using "magic" numbers
Submitter:
Date:
2023-07-23 15:45:03 UTC
Severity:
normal
Tags:
#1041041#5
Date:
2023-07-14 10:53:34 UTC
From:
To:
Dear Maintainer,

`file` shows an extra leading zero for serial numbers of ntfs filesystems.

It shows 17 characters like 034f5ee1202469ff7 instead of the correct 16 characters like 34f5ee1202469ff7 or with 0x prepended like 0x34f5ee1202469ff7 as it does it for FAT32.

Steps to reproduce:

1) Create a new container for testing:
$ fallocate --length 1G ./mycontainer

2) Format it as a reproducible ntfs filesystem:
$ /sbin/mkfs.ntfs --fast --zero-time --force ./mycontainer

3) Run file on it:
$ file ./mycontainer

4) Observe this output:
./mycontainer: DOS/MBR boot sector, code offset 0x52+2, OEM-ID "NTFS    ", sectors/cluster 8, Media descriptor 0xf8, sectors/track 0, dos < 4.0 BootSector (0x80), FAT (1Y bit by descriptor); NTFS, sectors 2097151, $MFT start cluster 4, $MFTMirror start cluster 131071, bytes/RecordSegment 2^(-1*246), clusters/index block 1, serial number 034f5ee1202469ff7

Notice the serial number at the end of the message is displayed as 034f5ee1202469ff7

This is 17 character, but it should be a 16 hexadecimal characters.

5) You can verify the serial number using:
$ /sbin/ntfslabel -v ./mycontainer

6) Observe it shows:
Serial number : 34f5ee1202469ff7
Volume label :

I propose that `file` should either drop the leading 0, so that it shows 34f5ee1202469ff7, or it should put an 'x' after the leading zero, like 0x34f5ee1202469ff7 similarly to how it does it for FAT32 filesystems.

Thank you and good luck!

#1041041#10
Date:
2023-07-23 15:31:15 UTC
From:
To:
sowg09+39vc9e5tpgdtw@cs.email wrote...

(...)

Well spotted, now forwarded to upstream.

Cheers,

    Christoph