Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3372)

Unified Diff: base/files/file_util_mac.mm

Issue 2770753006: [base/files] Respect MAC_CHROMIUM_TMPDIR instead of TMPDIR on macOS. (Closed)
Patch Set: comment Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/test_extension_dir.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/file_util_mac.mm
diff --git a/base/files/file_util_mac.mm b/base/files/file_util_mac.mm
index 5a99aa0e81de2e19110872cc168e53b93555d0c5..d3e14a37870faa5be28dd730b2ac126c81180e32 100644
--- a/base/files/file_util_mac.mm
+++ b/base/files/file_util_mac.mm
@@ -7,8 +7,10 @@
#import <Foundation/Foundation.h>
#include <copyfile.h>
#include <stdlib.h>
+#include <string.h>
#include "base/files/file_path.h"
+#include "base/logging.h"
#include "base/mac/foundation_util.h"
#include "base/strings/string_util.h"
#include "base/threading/thread_restrictions.h"
@@ -24,10 +26,14 @@ bool CopyFile(const FilePath& from_path, const FilePath& to_path) {
}
bool GetTempDir(base::FilePath* path) {
- // In order to facilitate hermetic runs on macOS, first check $TMPDIR.
- // NOTE: $TMPDIR is ALMOST ALWAYS set on macOS (unless the user un-set it).
- const char* env_tmpdir = getenv("TMPDIR");
+ // In order to facilitate hermetic runs on macOS, first check
+ // $MAC_CHROMIUM_TMPDIR. We check this instead of $TMPDIR because external
+ // programs currently set $TMPDIR with no effect, but when we respect it
+ // directly it can cause crashes (like crbug.com/698759).
+ const char* env_tmpdir = getenv("MAC_CHROMIUM_TMPDIR");
if (env_tmpdir) {
+ DCHECK_LT(strlen(env_tmpdir), 50u)
+ << "too-long TMPDIR causes socket name length issues.";
*path = base::FilePath(env_tmpdir);
return true;
}
« no previous file with comments | « no previous file | chrome/browser/extensions/test_extension_dir.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698