1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2024-11-28 10:24:20 +01:00

Normalize paths when comparing. (fixes #37). (#38)

When resolving bin paths from gameinfo to platform-specific absolute paths, we end
up with ".." instances on x64, causing the paths being compared to look different. MM:S
then cannot differentiate it's server bin path from the game's server bin, causing us to
load ourselves as the server bin over and over again, causing a stack overflow.
This commit is contained in:
Nicholas Hastings 2018-01-28 11:49:28 -05:00 committed by GitHub
parent d6ee3bfaae
commit 30c6e9107d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -225,6 +225,30 @@ mm_KeySplit(const char *str, char *buf1, size_t len1, char *buf2, size_t len2)
bool
mm_PathCmp(const char *path1, const char *path2)
{
#ifdef _WIN32
char szFullPath1[PLATFORM_MAX_PATH];
char szFullPath2[PLATFORM_MAX_PATH];
if (GetFullPathName(path1, sizeof(szFullPath1), szFullPath1, nullptr) != 0)
{
path1 = szFullPath1;
}
if (GetFullPathName(path2, sizeof(szFullPath2), szFullPath2, nullptr) != 0)
{
path2 = szFullPath2;
}
#else
char szFullPath1[PATH_MAX + 1];
char szFullPath2[PATH_MAX + 1];
if (realpath(path1, szFullPath1))
{
path1 = szFullPath1;
}
if (realpath(path2, szFullPath2))
{
path2 = szFullPath2;
}
#endif
size_t pos1 = 0, pos2 = 0;
while (true)