darlinghq / darling-dmg

FUSE module for .dmg files (containing an HFS+ filesystem)
http://www.darlinghq.org
GNU General Public License v3.0
273 stars 45 forks source link

crash: Wrong kind of BTree header #29

Open tomkoen opened 9 years ago

tomkoen commented 9 years ago

Just have encounted a DMG file (Apple Service Diagnostic 3S135.dmg, 3.55 GB) that throws this type of exception (in HFSBTree::HFSBTree) when constructing HFSExtentsOverflowBTree After this, the app crashes in CachedReader::nonCachedRead throw std::logic_error("Range returned by adviseOptimalBlock() is too large");

tomkoen commented 9 years ago

The DMG to reproduce: https://www.dropbox.com/s/1si6j71ak4jxny7/Apple%20Service%20Diagnostic%203S135.dmg?dl=0

LubosD commented 9 years ago

I can confirm the issue with adviseOptimalBlock(), but I haven't yet seen the HFSExtentsOverflowBTree problem.

tomkoen commented 9 years ago

I can confirm that std::logic_error("Range returned by adviseOptimalBlock() is too large"); is fixed, thanks! but "Wrong kind of BTree header" can be reproduced in this way (sorry not to mention it earlier):

// if (DMGDisk::isDMG(g_fileReader)) // if we skip DMG check
//      g_partitions.reset(new DMGDisk(g_fileReader));
//  else 
if (GPTDisk::isGPTDisk(g_fileReader))
        g_partitions.reset(new GPTDisk(g_fileReader));
    else if (AppleDisk::isAppleDisk(g_fileReader))
        g_partitions.reset(new AppleDisk(g_fileReader));
    else if (HFSVolume::isHFSPlus(g_fileReader)) // this is TRUE!
        volume.reset(new HFSVolume(g_fileReader)); // here is exception
    else
        throw function_not_implemented_error("Unsupported file format");

It might not be an error I understand

LubosD commented 9 years ago

Is is an error, which would normally prevent the image from being mounted on Linux, but it just doesn't happen here. I'll download the file again from your DropBox, maybe it's different?

tomkoen commented 9 years ago

Sorry but it doesn't happen when trying to mount the file as DMG. For some reason HFSVolume::isHFSPlus gives true for this file and then

volume.reset(new HFSVolume(g_fileReader));

gives exception

LubosD commented 9 years ago

Ah, I see. I'll take a look into that. But given that the .DMG file is itself RAW (=no compression used), it is entirely possible it may get misdetected.