Index: sandbox/linux/services/namespace_utils.cc |
diff --git a/sandbox/linux/services/namespace_utils.cc b/sandbox/linux/services/namespace_utils.cc |
index f03fe4080aa32ea49e383e784463dd30d24c8de2..81e096c1262d706ab3e1b3d922fc8b85f0a49c10 100644 |
--- a/sandbox/linux/services/namespace_utils.cc |
+++ b/sandbox/linux/services/namespace_utils.cc |
@@ -18,7 +18,7 @@ |
#include "base/logging.h" |
#include "base/posix/eintr_wrapper.h" |
#include "base/process/launch.h" |
-#include "base/strings/stringprintf.h" |
+#include "base/strings/safe_sprintf.h" |
#include "base/third_party/valgrind/valgrind.h" |
namespace sandbox { |
@@ -38,11 +38,14 @@ bool NamespaceUtils::WriteToIdMapFile(const char* map_file, generic_id_t id) { |
const generic_id_t inside_id = id; |
const generic_id_t outside_id = id; |
- const std::string mapping = |
- base::StringPrintf("%d %d 1\n", inside_id, outside_id); |
- const size_t len = mapping.size(); |
- const ssize_t rc = HANDLE_EINTR(write(fd.get(), mapping.c_str(), len)); |
- return rc == static_cast<ssize_t>(len); |
+ |
+ // This function needs to be async-signal-safe, as it is called in between |
jln (very slow on Chromium)
2015/02/03 01:14:30
Add this as a comment to the function instead.
rickyz (no longer on Chrome)
2015/02/03 01:27:22
Done.
|
+ // fork and exec. |
+ char mapping[64]; |
+ ssize_t len = |
+ base::strings::SafeSPrintf(mapping, "%d %d 1\n", inside_id, outside_id); |
+ const ssize_t rc = HANDLE_EINTR(write(fd.get(), mapping, len)); |
+ return rc == len; |
} |
// static |