From c60da6cebac7d528a2a7684e92c102d6283374c8 Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Wed, 4 Dec 2024 14:11:29 -0800 Subject: [PATCH] Handle not truncating root folder in CorUnix::InternalCanonicalizeRealPath for all architectures instead of only amd64 --- src/coreclr/pal/src/file/file.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/coreclr/pal/src/file/file.cpp b/src/coreclr/pal/src/file/file.cpp index 382a448c659fcc..4d95333e649b33 100644 --- a/src/coreclr/pal/src/file/file.cpp +++ b/src/coreclr/pal/src/file/file.cpp @@ -334,7 +334,6 @@ CorUnix::InternalCanonicalizeRealPath(LPCSTR lpUnixPath, PathCharString& lpBuffe } else { -#if defined(HOST_AMD64) bool fSetFilename = true; // Since realpath implementation cannot handle inexistent filenames, // check if we are going to truncate the "/" corresponding to the @@ -358,8 +357,9 @@ CorUnix::InternalCanonicalizeRealPath(LPCSTR lpUnixPath, PathCharString& lpBuffe fSetFilename = false; } else -#endif // defined(HOST_AMD64) + { *pchSeparator = '\0'; + } if (!RealPathHelper(lpExistingPath, lpBuffer)) { @@ -368,16 +368,12 @@ CorUnix::InternalCanonicalizeRealPath(LPCSTR lpUnixPath, PathCharString& lpBuffe goto LExit; } -#if defined(HOST_AMD64) if (fSetFilename == true) -#endif // defined(HOST_AMD64) lpFilename = pchSeparator + 1; } -#if defined(HOST_AMD64) if (lpFilename == NULL) goto LExit; -#endif // HOST_AMD64 if (!lpBuffer.Append("/",1) || !lpBuffer.Append(lpFilename, strlen(lpFilename))) {