fragglet / lhasa

Free Software LHA implementation
http://fragglet.github.io/lhasa/
ISC License
80 stars 15 forks source link

Lhasa cannot extract empty directories from amiga lha archives. #37

Closed alfredone closed 1 year ago

alfredone commented 2 years ago

lhasa stops unpacking an archive when it encounters an empty directory. Tested with an amiga lha archive.

alfredone commented 2 years ago

MainDir.lha.zip

This is the content of MainDir.lha:

MainDir

00_File.txt 01_Dir

File01.txt

02_EmptyDir 03_Dir

File01.txt

04_File.txt

Extracting with lhasa gives the following result:

MainDir

00_File.txt 01_Dir

File01.txt

jsummers commented 2 years ago

This is probably the same issue as issue #31.

The problem is that the item that should have been a directory (type "lhd") is erroneously stored as a regular file (type "lh0"), due to a bug in whatever program created the LHA file. The item does not have a filename; it only has a directory name. Lhasa treats a file without a filename as a fatal error.

fragglet commented 1 year ago

Can confirm this is the same issue as #31:

00000070  ff 05 00 00 c6 53 00 00  46 69 6c 65 30 31 19 4c  |.....S..File01.L|
                                                     \_ start of header

00000080  2d 6c 68 30 2d 1c 00 00  00 00 00 00 00 53 a7 2b  |-lh0-........S.+|
00000090  54 00 01 00 00 00 41 17  00 02 4d 61 69 6e 44 69  |T.....A...MainDi|
                  |                   \_ start of path header
                   \_ length of filename = 0

000000a0  72 ff 30 32 5f 45 6d 70  74 79 44 69 72 ff 05 00  |r.02_EmptyDir...|
000000b0  00 0f 31 00 00 23 a5 2d  6c 68 30 2d 1d 00 00 00  |..1..#.-lh0-....|
         |         \_ no next header; end of headers
          \_ start of common header