[Scummvm-git-logs] scummvm master -> 754827c68d9811fed81be215e148b232ec7338dd

sev- noreply at scummvm.org
Tue Nov 12 00:10:57 UTC 2024


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
c6daf24573 COMMON: Add Path::numComponents() method
754827c68d COMMON: Avoid scanning out of game directory for AppleDouble files. Bug #15016


Commit: c6daf245730d301374f3260438c6028b5b719d6b
    https://github.com/scummvm/scummvm/commit/c6daf245730d301374f3260438c6028b5b719d6b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-11-12T01:10:46+01:00

Commit Message:
COMMON: Add Path::numComponents() method

Changed paths:
    common/path.cpp
    common/path.h


diff --git a/common/path.cpp b/common/path.cpp
index 4d06cc6dccf..1d289ac3020 100644
--- a/common/path.cpp
+++ b/common/path.cpp
@@ -405,6 +405,27 @@ String Path::baseName() const {
 	return unescape(kNoSeparator, begin, end);
 }
 
+int Path::numComponents() const {
+	if (_str.empty())
+		return 0;
+
+	const char *str = _str.c_str();
+
+	if (isEscaped())
+		str++;
+
+	int num = 1;
+
+	const char *sep = strchr(str, SEPARATOR);
+	while (sep) {
+		str = sep + 1;
+		sep = strchr(str, SEPARATOR);
+		num++;
+	}
+
+	return num;
+}
+
 Path &Path::appendInPlace(const Path &x) {
 	if (x._str.empty()) {
 		return *this;
diff --git a/common/path.h b/common/path.h
index 1b77d76c162..0da427e8c4e 100644
--- a/common/path.h
+++ b/common/path.h
@@ -304,6 +304,11 @@ public:
 	 */
 	String baseName() const;
 
+	/**
+	 * Returns number of components in this path,
+	 */
+	int numComponents() const;
+
 	/** Check whether this path is identical to path @p x. */
 	bool operator==(const Path &x) const {
 		return _str == x._str;


Commit: 754827c68d9811fed81be215e148b232ec7338dd
    https://github.com/scummvm/scummvm/commit/754827c68d9811fed81be215e148b232ec7338dd
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-11-12T01:10:47+01:00

Commit Message:
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.

Changed paths:
    common/macresman.cpp


diff --git a/common/macresman.cpp b/common/macresman.cpp
index 6b315c4e5a3..2443af82d75 100644
--- a/common/macresman.cpp
+++ b/common/macresman.cpp
@@ -174,13 +174,24 @@ SeekableReadStream *MacResManager::openAppleDoubleWithAppleOrOSXNaming(Archive&
 		return stream;
 
 	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
 	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())
 		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;
 		int j;
 		for (j = 0; j < i; j++)




More information about the Scummvm-git-logs mailing list