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..652cc0efac855750b8841466964dd43fc2b13c58 100644 |
--- a/base/files/file_util_mac.mm |
+++ b/base/files/file_util_mac.mm |
@@ -2,13 +2,13 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "base/files/file_util.h" |
- |
#import <Foundation/Foundation.h> |
#include <copyfile.h> |
#include <stdlib.h> |
#include "base/files/file_path.h" |
+#include "base/files/file_util.h" |
Mark Mentovai
2017/03/28 00:20:23
This was correct where it was before.
iannucci
2017/03/28 00:24:04
Presumit was hollering at me about this (my origin
Mark Mentovai
2017/03/28 00:27:14
Presubmit’s wrong, NOPRESUBMIT it if you have to,
|
+#include "base/logging.h" |
#include "base/mac/foundation_util.h" |
#include "base/strings/string_util.h" |
#include "base/threading/thread_restrictions.h" |
@@ -24,10 +24,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), 50) |
iannucci
2017/03/28 00:10:59
NSTemporaryDirectory() length is 49.
Mark Mentovai
2017/03/28 00:20:23
#inclue <string.h> for this.
iannucci
2017/03/28 00:24:04
er... whoops.
|
+ << "too-long TMPDIR causes socket name length issues."; |
*path = base::FilePath(env_tmpdir); |
return true; |
} |