matthewbauer / undmg

extract a dmg file
GNU General Public License v3.0
33 stars 8 forks source link

segfaults on some mkl dmgs #4

Open tscholak opened 5 years ago

tscholak commented 5 years ago

http://registrationcenter-download.intel.com/akdlm/irc_nas/tec/15235/m_mkl_2019.3.199.dmg

http://registrationcenter-download.intel.com/akdlm/irc_nas/tec/15481/m_mkl_2019.4.233.dmg

http://registrationcenter-download.intel.com/akdlm/irc_nas/tec/15822/m_mkl_2019.5.281.dmg

undmg only works on the first one, but segfaults on the latter two.

veprbl commented 5 years ago

This issue prevents us from bumping mkl version on darwin in nixpkgs.

veprbl commented 5 years ago

Unpacking the dmg file using 7z [1], it seems like the reason why the new files don't work might be because they use APFS instead of HFS:

0.MBR
1.Primary GPT Header
2.Primary GPT Table
3.free
4.Apple_APFS
5.free
6.Backup GPT Table
7.Backup GPT Header

[1] https://stackoverflow.com/a/28641849

matthewbauer commented 4 years ago

Confirmed that this is from APFS volumes. I've pushed a change to avoid the segfault and explain what's going on. But supporting this will probably require implementing APFS, which it looks like has been done in https://github.com/sgan81/apfs-fuse.

what-the-functor commented 4 years ago

@matthewbauer Is there a known work-around for APFS DMG volumes?

matthewbauer commented 4 years ago

You can mount the dmg file with https://github.com/sgan81/apfs-fuse

what-the-functor commented 4 years ago

I started to add Darwin compatibility for apfs-fuse, but it's not compiling on 10.14.6. I think that, there are API differences between Fuse3 on Linux, and osxfuse. tonylotts/nixpkgs@bce2353ea85652bb676e1b70e88726c833aef921

veprbl commented 3 years ago

https://github.com/linux-apfs/linux-apfs-rw

cyounkins commented 3 years ago

The second provided file appears to suffer the same issue as in #8 - extraction does not segfault when used as a parameter. There may still be an issue with a non-HFS file system.

$ undmg < m_mkl_2019.4.233.dmg
error: only HFS file systems are supported.
fish: Job 1, 'undmg < m_mkl_2019.4.233.dmg' terminated by signal SIGSEGV (Address boundary error)
$ undmg m_mkl_2019.4.233.dmg
error: only HFS file systems are supported.
$
ldeck commented 1 year ago

@matthewbauer I've only just started seeing this for my home-manager based config which has some macOS apps defined as modules.

My understanding is that APFS volumes may be becoming more prevalent, which presumably means a fix for undmg's support for APFS would be awesome to see asap.

e.g., Authy Desktop-2.2.3.dmg complains with undmg that it's not an HFS volume. See this discourse discussion for more details.

What work-arounds (if any) or fixes can we help with to fix this? i.e., any workaround I could implement in my app.nix function to allow such dmgs to be handled?

ldeck commented 1 year ago

FYI @matthewbauer

 % hdiutil imageinfo ~/Downloads/Authy\ Desktop-2.2.3.dmg 
Format Description: UDIF read-only compressed (zlib)
Class Name: CUDIFDiskImage
Checksum Type: CRC32
Size Information:
    CUDIFEncoding-bytes-total: 87733814
    Total Empty Bytes: 51668992
    Sector Count: 507239
    Total Bytes: 259706368
    CUDIFEncoding-bytes-wasted: 0
    Total Non-Empty Bytes: 208037376
    Compressed Ratio: 0.42172114303152908
    CUDIFEncoding-bytes-in-use: 87733814
    Compressed Bytes: 87733814
Checksum Value: $434F73B4
Segments:
    0: /Users/ldeck/Downloads/Authy Desktop-2.2.3.dmg
Partition Information:
    3:
        Name: disk image (Apple_APFS : 4)
        Partition Number: 3
        Checksum Type: CRC32
        Checksum Value: $C9BE1AAB
    4:
        Name:  (Apple_Free : 5)
        Partition Number: 4
        Checksum Type: CRC32
        Checksum Value: $00000000
    0:
        Name: GPT Header (Primary GPT Header : 1)
        Partition Number: 0
        Checksum Type: CRC32
        Checksum Value: $062A8CF5
    5:
        Name: GPT Partition Data (Backup GPT Table : 6)
        Partition Number: 5
        Checksum Type: CRC32
        Checksum Value: $71DF69C2
    1:
        Name: GPT Partition Data (Primary GPT Table : 2)
        Partition Number: 1
        Checksum Type: CRC32
        Checksum Value: $71DF69C2
    6:
        Name: GPT Header (Backup GPT Header : 7)
        Partition Number: 6
        Checksum Type: CRC32
        Checksum Value: $C4FD59BC
    -1:
        Name: Protective Master Boot Record (MBR : 0)
        Partition Number: -1
        Checksum Type: CRC32
        Checksum Value: $BCE30DFA
    2:
        Name:  (Apple_Free : 3)
        Partition Number: 2
        Checksum Type: CRC32
        Checksum Value: $00000000
Format: UDZO
Backing Store Information:
    URL: file:///Users/ldeck/Downloads/Authy%20Desktop-2.2.3.dmg
    Name: Authy Desktop-2.2.3.dmg
    Class Name: CUDIFEncoding
    Backing Store Information:
        URL: file:///Users/ldeck/Downloads/Authy%20Desktop-2.2.3.dmg
        Name: Authy Desktop-2.2.3.dmg
        Class Name: CBSDBackingStore
partitions:
    partition-scheme: GUID
    block-size: 512
    partitions:
        0:
            partition-name: Protective Master Boot Record
            partition-start: 0
            partition-synthesized: true
            partition-length: 1
            partition-hint: MBR
        1:
            partition-name: GPT Header
            partition-start: 1
            partition-synthesized: true
            partition-length: 1
            partition-hint: Primary GPT Header
        2:
            partition-name: GPT Partition Data
            partition-start: 2
            partition-synthesized: true
            partition-length: 32
            partition-hint: Primary GPT Table
        3:
            partition-name: 
            partition-start: 34
            partition-synthesized: true
            partition-length: 6
            partition-hint: Apple_Free
        4:
            partition-UUID: B7FB4DBD-9EA0-459E-8241-085BCFBF4D69
            partition-name: disk image
            partition-hint-UUID: 7C3457EF-0000-11AA-AA11-00306543ECAC
            partition-start: 40
            partition-number: 1
            partition-length: 507163
            partition-hint: Apple_APFS
            partition-filesystems:
                APFS: Untitled
        5:
            partition-name: 
            partition-start: 507203
            partition-synthesized: true
            partition-length: 3
            partition-hint: Apple_Free
        6:
            partition-name: GPT Partition Data
            partition-start: 507206
            partition-synthesized: true
            partition-length: 32
            partition-hint: Backup GPT Table
        7:
            partition-name: GPT Header
            partition-start: 507238
            partition-synthesized: true
            partition-length: 1
            partition-hint: Backup GPT Header
    burnable: false
udif-ordered-chunks: true
Properties:
    Encrypted: false
    Kernel Compatible: true
    Checksummed: true
    Software License Agreement: false
    Partitioned: false
    Compressed: true
Resize limits (per hdiutil resize -limits):
 min     cur     max 
430080  507163  507163