| Index: kernel_collector.cc
|
| diff --git a/kernel_collector.cc b/kernel_collector.cc
|
| index c95873347dd435b1247e093fb69d0cd1623450e4..4fa51e26e7d2752e494defbca0f5e870323af38d 100644
|
| --- a/kernel_collector.cc
|
| +++ b/kernel_collector.cc
|
| @@ -277,9 +277,12 @@ bool KernelCollector::Collect() {
|
| FilePath kernel_crash_path = root_crash_directory.Append(
|
| StringPrintf("%s.kcrash", dump_basename.c_str()));
|
|
|
| - if (file_util::WriteFile(kernel_crash_path,
|
| - kernel_dump.data(),
|
| - kernel_dump.length()) !=
|
| + // We must use WriteNewFile instead of file_util::WriteFile as we
|
| + // do not want to write with root access to a symlink that an attacker
|
| + // might have created.
|
| + if (WriteNewFile(kernel_crash_path,
|
| + kernel_dump.data(),
|
| + kernel_dump.length()) !=
|
| static_cast<int>(kernel_dump.length())) {
|
| logger_->LogInfo("Failed to write kernel dump to %s",
|
| kernel_crash_path.value().c_str());
|
|
|