Bug 476196 - Ark fails to parse 7z archive if it was created with attributes omitted ('-mtr=off')
Summary: Ark fails to parse 7z archive if it was created with attributes omitted ('-mt...
Status: RESOLVED FIXED
Alias: None
Product: ark
Classification: Applications
Component: plugins (show other bugs)
Version: 23.08.1
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Elvis Angelaccio
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-10-28 13:08 UTC by Hanabishi
Modified: 2024-04-25 12:47 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 24.05


Attachments
Test archive (168 bytes, application/x-7z-compressed)
2023-10-28 15:10 UTC, Hanabishi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hanabishi 2023-10-28 13:08:53 UTC
SUMMARY
Ark fails to parse 7z archive if it was created with attributes omitted ('-mtr=off').

STEPS TO REPRODUCE
1. Create a 7z archive, containing directories, with '-mtr=off' flag.
2. Open the archive in Ark.

OBSERVED RESULT
Ark fails to parse the archive properly.

EXPECTED RESULT
Ark should parse the archive properly.

SOFTWARE/OS VERSIONS
Ark 23.08.2

ADDITIONAL INFORMATION

This is because Ark relies on 'D' attribute to detect directories inside 7z archives.
https://invent.kde.org/utilities/ark/-/blob/8c7e0a2117fc6db538b3df33b19e9b910f07c160/plugins/cli7zplugin/cliplugin.cpp#L259

Usually archive records look like this:

Path = test
Size = 0
Packed Size = 0
Modified = 2023-10-28 12:52:18.4874650
Attributes = D drwxr-xr-x
CRC =
Encrypted = -
Method =
Block =

But when '-mtr=off' flag is used during archive creation, all attribuites are omitted:

Path = test
Size = 0
Packed Size = 0
Modified = 2023-10-28 12:52:18.4874650
CRC =
Encrypted = -
Method =
Block =

So Ark fails to detect it as a directory.
Comment 1 Hanabishi 2023-10-28 13:14:50 UTC
The problem is, seems like there is no way to distinguish between directories and empty files via 7z CLI, without relying on attributes.

Path = test
Size = 0
Packed Size = 0
Modified = 2023-10-28 13:10:47.8804270
CRC =
Encrypted = -
Method =
Block =

Path = test/test
Size = 0
Packed Size = 0
Modified = 2023-10-28 13:10:49.8933970
CRC =
Encrypted = -
Method =
Block =

The first record is a directory, the second is an empty file.
Comment 2 Hanabishi 2023-10-28 14:40:53 UTC
By the way, opening such archive in debug build causes Ark to crash with failed assertion.

ASSERT: "isDir()" in file /ark/kerfuffle/archiveentry.cpp, line 90
[1]    18771 IOT instruction (core dumped)  ark /test.7z
Comment 3 Hanabishi 2023-10-28 15:10:36 UTC
Created attachment 162616 [details]
Test archive

Test archive made with '-mtr=off', just in case.
Comment 4 Elvis Angelaccio 2024-04-25 12:47:19 UTC
I'll mark this one as fixed. As discussed on gitlab, the new libarchive-based 7z backend can handle these kind of archives just fine.