From f2e95303a1fbfaba34b7a3b42e9eb849d61b0eb4 Mon Sep 17 00:00:00 2001 From: Bob Owen Date: Mon, 3 Aug 2015 07:58:43 +0100 Subject: [PATCH] Bug 1189352: Fix NSPR_LOG_FILE with absolute paths for sandboxed child on Windows. r=bbondy --- ipc/glue/GeckoChildProcessHost.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/ipc/glue/GeckoChildProcessHost.cpp b/ipc/glue/GeckoChildProcessHost.cpp index e90f521298f..1441cc07a66 100644 --- a/ipc/glue/GeckoChildProcessHost.cpp +++ b/ipc/glue/GeckoChildProcessHost.cpp @@ -564,26 +564,27 @@ MaybeAddNsprLogFileAccess(std::vector& aAllowedFilesReadWrite) return; } - nsCOMPtr file; - nsresult rv = NS_GetSpecialDirectory(NS_OS_CURRENT_WORKING_DIR, - getter_AddRefs(file)); - if (NS_FAILED(rv) || !file) { - NS_WARNING("Failed to get current working directory"); - return; - } - - nsDependentCString nsprLogFile(nsprLogFileEnv); - rv = file->AppendRelativeNativePath(nsprLogFile); + nsDependentCString nsprLogFilePath(nsprLogFileEnv); + nsCOMPtr nsprLogFile; + nsresult rv = NS_NewNativeLocalFile(nsprLogFilePath, true, + getter_AddRefs(nsprLogFile)); if (NS_FAILED(rv)) { - // Not a relative path, try it as an absolute one. - rv = file->InitWithNativePath(nsprLogFile); + // Not an absolute path, try it as a relative one. + nsresult rv = NS_GetSpecialDirectory(NS_OS_CURRENT_WORKING_DIR, + getter_AddRefs(nsprLogFile)); + if (NS_FAILED(rv) || !nsprLogFile) { + NS_WARNING("Failed to get current working directory"); + return; + } + + rv = nsprLogFile->AppendRelativeNativePath(nsprLogFilePath); if (NS_WARN_IF(NS_FAILED(rv))) { return; } } nsAutoString resolvedFilePath; - rv = file->GetPath(resolvedFilePath); + rv = nsprLogFile->GetPath(resolvedFilePath); if (NS_WARN_IF(NS_FAILED(rv))) { return; }