Skip to content

Commit 50c5dc4

Browse files
committed
[SharedCache] Stop crashing if we don't have a valid dyld in PerformInitialLoad
Still need to decide on how we want handle this, because we need multiple files we probably just want to prompt the user for a directory?
1 parent b92bfab commit 50c5dc4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

view/sharedcache/core/SharedCache.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,12 +472,14 @@ void SharedCache::PerformInitialLoad(std::lock_guard<std::mutex>& lock)
472472
initialState.baseFilePath = path;
473473
initialState.cacheFormat = RegularCacheFormat;
474474

475+
// TODO: If this fails we should prompt the user to select there file, this probably means that
476+
// TODO: They are opening a database with no original file path.
475477
DataBuffer sig = baseFile->ReadBuffer(0, 4);
476478
if (sig.GetLength() != 4)
477-
abort();
479+
throw std::runtime_error("Not a valid dyld_shared_cache file");
478480
const char* magic = (char*)sig.GetData();
479481
if (strncmp(magic, "dyld", 4) != 0)
480-
abort();
482+
throw std::runtime_error("Not a valid dyld_shared_cache file");
481483

482484
dyld_cache_header primaryCacheHeader {};
483485
size_t header_size = baseFile->ReadUInt32(16);
@@ -1467,9 +1469,9 @@ SharedCache::SharedCache(BinaryNinja::Ref<BinaryNinja::BinaryView> dscView) :
14671469
try {
14681470
PerformInitialLoad(lock);
14691471
}
1470-
catch (...)
1472+
catch (std::exception& e)
14711473
{
1472-
m_logger->LogError("Failed to perform initial load of Shared Cache");
1474+
m_logger->LogError("Failed to perform initial load of Shared Cache: %s", e.what());
14731475
}
14741476

14751477
auto settings = m_dscView->GetLoadSettings(VIEW_NAME);

0 commit comments

Comments
 (0)