mirror of
https://github.com/libretro/scummvm.git
synced 2024-11-23 09:19:55 +00:00
COMMON: Avoid scanning out of game directory for AppleDouble files. Bug #15016
Also implement sanity check for paths containing drive, e.g. "Games:" on Amiga or "D:" on Windows.
This commit is contained in:
parent
c6daf24573
commit
754827c68d
@ -174,13 +174,24 @@ SeekableReadStream *MacResManager::openAppleDoubleWithAppleOrOSXNaming(Archive&
|
|||||||
return stream;
|
return stream;
|
||||||
|
|
||||||
const ArchiveMemberPtr archiveMember = archive.getMember(fileName);
|
const ArchiveMemberPtr archiveMember = archive.getMember(fileName);
|
||||||
const Common::FSNode *plainFsNode = dynamic_cast<const Common::FSNode *>(archiveMember.get());
|
const Common::FSNode *plainFsNode = dynamic_cast<const Common::FSNode *>(archiveMember.get());
|
||||||
|
|
||||||
// Try finding __MACOSX
|
// Try finding __MACOSX
|
||||||
Common::StringArray components = (plainFsNode ? plainFsNode->getPath() : fileName).splitComponents();
|
Common::StringArray components = (plainFsNode ? plainFsNode->getPath() : fileName).splitComponents();
|
||||||
|
|
||||||
|
// We do not need to look beyond the root directory
|
||||||
|
// Fixes bug #15016
|
||||||
|
int start = MAX((int)components.size() - fileName.numComponents(), 0);
|
||||||
|
|
||||||
if (components.empty() || components[components.size() - 1].empty())
|
if (components.empty() || components[components.size() - 1].empty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
for (int i = components.size() - 1; i >= 0; i--) {
|
for (int i = components.size() - 1; i >= start; i--) {
|
||||||
|
// On Windows and Amiga we may have disk name followed
|
||||||
|
// by ':'. So, checking for that. Otherwise, we will generate
|
||||||
|
// paths like "__MACOSX:D/Games/._Data"
|
||||||
|
if (i == 0 && components[i].contains(':'))
|
||||||
|
break;
|
||||||
|
|
||||||
Common::StringArray newComponents;
|
Common::StringArray newComponents;
|
||||||
int j;
|
int j;
|
||||||
for (j = 0; j < i; j++)
|
for (j = 0; j < i; j++)
|
||||||
|
Loading…
Reference in New Issue
Block a user