View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000538 | file | General | public | 2024-07-06 16:11 | 2024-07-07 14:42 |
Reporter | dajhorn | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | always |
Status | new | Resolution | open | ||
Product Version | 5.45 | ||||
Summary | 0000538: RAR version 7 is not recognized | ||||
Description | The file utility incorrectly recognizes RAR v7 files as v5 files. | ||||
Steps To Reproduce | $ rar a -md8G -r v7test.rar * $ file v7test.rar v7test.rar: RAR archive data, v5 $ file --version file-5.45 magic file from /etc/magic:/usr/share/misc/magic $ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 24.04 LTS Release: 24.04 Codename: noble | ||||
Additional Information | RAR files with dictionaries larger than 4 gigabytes are always version 7. The expected result is: $ file v7test.rar v7test.rar: RAR archive data, v7 | ||||
Tags | No tags attached. | ||||
|
|
|
Somebody correct me if I'm wrong, but the format is still named RAR 5. It's covered in the document titled "RAR 5.0 archive format" (https://www.rarlab.com/technote.htm -- search for "RAR 7.0"). It might be good if 'file' printed something like "RAR archive data, v5, RAR v7 to extract" for such files. Though I don't think that would be simple to do, in part because of RAR5's variable-length integers. |
|
The RAR application version is often conflated with the RAR format version. In this case: * WinRAR 5 is format 5 version 0. * WinRAR 6 is format 5 version 0. * WinRAR 7 is format 5 version 1 (and possibly format 5 version 0 with a large dictionary). The enduser won't understand this implementation detail and will reasonably expect to see "v7" in the `file` result. Per the rarlab.com technical note, doing two bitwise tests in the existing service header are likely enough to recognize the latest archive revision: 1. Check the format and version: IF { compression_information & 0x003f > 0 } THEN RETURN v7 2. Check for a large dictionary: ELSE IF { compression_information & 0x7c00 > 15 } THEN RETURN v7 |
|
BTW, you are right that the `vint` type makes adding this check non-trivial. Dunno how the RAR subblock test in Magdir/archive might be modified to make it happen. |