MacPaw / XADMaster

Objective-C library for archive and file unarchiving and extraction
GNU Lesser General Public License v2.1
103 stars 43 forks source link

LSAR enters infinite loop on RAR v2 archive #111

Open kyeastmood opened 4 years ago

kyeastmood commented 4 years ago

When LSAR is invoked with "-L" option it enters an infinite loop on some RAR archives. This doesn't happen without "-L" parameter.' Version: 1.10.1/Debian Here's a link to such an archive (valid for 30 days): https://0x0.st/zC8M.rar

PaulTaykalo commented 4 years ago

thanks for pointing this out. will take a look what can be done. P.S. big kudos for providing example archive

kyeastmood commented 4 years ago

OK, thanks!

PaulTaykalo commented 4 years ago

This is likely a duplicate. https://github.com/MacPaw/XADMaster/pull/82/files

The issue is that there's a SOLID archive and it shown in a reference of 'Internal solid identifier' since there are a lot of files(1546) in one big chunk.

For each file in this chunk there'll be reference to 'Internal solid identifier' which will print the whole information about this chunk

-Part 1
-Internal solid identifier [Part1,Part2,Part3,Part4]
-Part 2
-Internal solid identifier [Part1,Part2,Part3,Part4]
-Part 3
-Internal solid identifier [Part1,Part2,Part3,Part4]
-Part 4
-Internal solid identifier [Part1,Part2,Part3,Part4]

This output explodes for huge number of files in the solid archive. The total output in this example will be approximately 640Kb * 1564 files ~ 1GB. You'll just need to wait

unar -L~/Downloads/zC8M.rar > ~/Desktop/result.txt  636.56s user 6.82s system 98% cpu 10:53.40 total
944M    ~/Desktop/result.txt

Previous solution was to add additional flag for removing 'Internal solid identifier' information from the output. If this option works in your case, I suggest adding an additional flag for this case as well.

kyeastmood commented 4 years ago

I cannot currently check this command-line parameters because they are not available yet in my version:

$ lsar
lsar v1.10.1, a tool for listing the contents of archive files.
Usage: lsar [options] archive [files ...]

Available options:
-long (-l)                      Print more information about each file in the archive.
-verylong (-L)                  Print all available information about each file in the archive.
-test (-t)                      Test the integrity of the files in the archive, if possible.
-password (-p) <string>         The password to use for decrypting protected archives.
-encoding (-e) <encoding name>  The encoding to use for filenames in the archive, when it is not known. If not specified, the program attempts to auto-detect the encoding used. Use "help" or "list" as the argument to give a listing of
                                all supported encodings.
-password-encoding (-E) <name>  The encoding to use for the password for the archive, when it is not known. If not specified, then either the encoding given by the -encoding option or the auto-detected encoding is used.
-print-encoding (-pe)           Print the auto-detected encoding and the confidence factor after the file list
-indexes (-i)                   Instead of specifying the files to list as filenames or wildcard patterns, specify them as indexes.
-json (-j)                      Print the listing in JSON format.
-json-ascii (-ja)               Print the listing in JSON format, encoded as pure ASCII text.
-no-recursion (-nr)             Do not attempt to list archives contained in other archives. For instance, when unpacking a .tar.gz file, only list the .gz file and not its contents.
-help (-h)                      Display this information.
-version (-v)                   Print version and exit.

However this is probably a good solution. May I only request a separate switch that works with plain output format (-L) and not with json output? It seems that when -json flag is set, listing errors are not printed and password prompt doesn't work. And even if errors were printed, they would end up inside json object that contains archive items (unless printed to error stream). Thanks

mirh commented 3 months ago

I think this is generally a problem with rar files, or maybe extracting too many files (possibly with a too long path) at once. Whereas 7-zip is done in just a few seconds, unar cannot be done even after a hour.