diff --git a/mozilla/xpcom/io/nsDirectoryService.cpp b/mozilla/xpcom/io/nsDirectoryService.cpp index 973f760fe55..46307e57da6 100644 --- a/mozilla/xpcom/io/nsDirectoryService.cpp +++ b/mozilla/xpcom/io/nsDirectoryService.cpp @@ -252,31 +252,29 @@ nsDirectoryService::GetCurrentProcessDirectory(nsILocalFile** aFile) if (moz5) { - localFile->InitWithNativePath(nsDependentCString(moz5)); - localFile->Normalize(); - *aFile = localFile; - return NS_OK; - } - else - { -#if defined(DEBUG) - static PRBool firstWarning = PR_TRUE; - - if(firstWarning) { - // Warn that MOZILLA_FIVE_HOME not set, once. - printf("Warning: MOZILLA_FIVE_HOME not set.\n"); - firstWarning = PR_FALSE; - } -#endif /* DEBUG */ - - // Fall back to current directory. - if (getcwd(buf, sizeof(buf))) - { + if (realpath(moz5, buf)) { localFile->InitWithNativePath(nsDependentCString(buf)); *aFile = localFile; return NS_OK; } } +#if defined(DEBUG) + static PRBool firstWarning = PR_TRUE; + + if(!moz5 && firstWarning) { + // Warn that MOZILLA_FIVE_HOME not set, once. + printf("Warning: MOZILLA_FIVE_HOME not set.\n"); + firstWarning = PR_FALSE; + } +#endif /* DEBUG */ + + // Fall back to current directory. + if (getcwd(buf, sizeof(buf))) + { + localFile->InitWithNativePath(nsDependentCString(buf)); + *aFile = localFile; + return NS_OK; + } #elif defined(XP_OS2) PPIB ppib; diff --git a/mozilla/xpcom/io/nsLocalFileUnix.cpp b/mozilla/xpcom/io/nsLocalFileUnix.cpp index 281113e8292..de6a41b4c4c 100644 --- a/mozilla/xpcom/io/nsLocalFileUnix.cpp +++ b/mozilla/xpcom/io/nsLocalFileUnix.cpp @@ -270,6 +270,9 @@ nsLocalFile::InitWithNativePath(const nsACString &filePath) } mPath = homePath + Substring(filePath, 1, filePath.Length() - 1); + } else if (filePath.IsEmpty() || filePath.First() != '/') { + NS_ERROR("Relative paths not allowed"); + return NS_ERROR_FILE_UNRECOGNIZED_PATH; } else { mPath = filePath; }