Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions view/sharedcache/core/SharedCacheView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,6 @@ bool SharedCacheView::Init()

m_logger = new Logger("SharedCache.View", GetFile()->GetSessionId());

uint32_t platform;
// NOTE: This entry only exists on ios 11 and later, older versions will just assume iOS.
GetParentView()->Read(&platform, 0xd8, 4);
char magic[17];
GetParentView()->Read(&magic, 0, 16);
magic[16] = 0;
Expand All @@ -197,6 +194,19 @@ bool SharedCacheView::Init()
return false;
}

// Use the value of mappingOffset as an upper bound for the size of the
// header to avoid misinterpreting bytes outside of the header.
uint32_t mappingOffset;
GetParentView()->Read(&mappingOffset, 0x10, 4);

uint32_t platform;
if (mappingOffset >= 0xd8 + 4) {
GetParentView()->Read(&platform, 0xd8, 4);
} else {
m_logger->LogWarn("Old header without platform field: Defaulting to iOS");
platform = DSCPlatformiOS;
}

// TODO: Do we want to add any warnings about platform support here?
// TODO: Do we still consider macos experimental?
switch (platform)
Expand Down