View Issue Details

IDProjectCategoryView StatusLast Update
0000538fileGeneralpublic2025-06-12 13:48
Reporterdajhorn Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Product Version5.45 
Summary0000538: RAR version 7 is not recognized
DescriptionThe 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 InformationRAR files with dictionaries larger than 4 gigabytes are always version 7. The expected result is:

$ file v7test.rar
v7test.rar: RAR archive data, v7
TagsNo tags attached.

Activities

dajhorn

2024-07-06 16:11

reporter  

WinRAR 7 Screenshot.png (6,826 bytes)   
WinRAR 7 Screenshot.png (6,826 bytes)   

jsummers

2024-07-06 19:20

reporter   ~0004059

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.

dajhorn

2024-07-07 14:20

reporter   ~0004060

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

dajhorn

2024-07-07 14:42

reporter   ~0004061

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.

christos

2025-06-01 14:56

manager   ~0004258

It should be pretty simple. file already has support for "varint"...

jsummers

2025-06-12 13:48

reporter   ~0004266

There's some "varint" stuff in the source code, but it doesn't seem to be in working order. The farthest I can get is the error "invalid type 51 in mconvert".

Note that RAR5 uses varints for things like segment sizes. To even get started parsing it properly, we'd have to be able to use varints in indirect offsets. (I'm *not* saying that would be *sufficient*! Maybe RAR5 would be hopeless anyway. I don't know.)

Issue History

Date Modified Username Field Change
2024-07-06 16:11 dajhorn New Issue
2024-07-06 16:11 dajhorn File Added: WinRAR 7 Screenshot.png
2024-07-06 19:20 jsummers Note Added: 0004059
2024-07-07 14:20 dajhorn Note Added: 0004060
2024-07-07 14:42 dajhorn Note Added: 0004061
2025-06-01 14:56 christos Note Added: 0004258
2025-06-12 13:48 jsummers Note Added: 0004266