Changes to fix build warnings on newer versions of GCC, and a fix to not try to open certain mapped files.
A=ZhurunZ, Tristan Schmelcher
R=nealsid
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@593 4c0a9323-5329-0410-9bdc-e9ce6186880e
diff --git a/src/client/linux/minidump_writer/linux_dumper.cc b/src/client/linux/minidump_writer/linux_dumper.cc
index be199f7..c693e90 100644
--- a/src/client/linux/minidump_writer/linux_dumper.cc
+++ b/src/client/linux/minidump_writer/linux_dumper.cc
@@ -59,6 +59,8 @@
#include "common/linux/linux_libc_support.h"
#include "common/linux/linux_syscall_support.h"
+static const char kMappedFileUnsafePrefix[] = "/dev/";
+
// Suspend a thread by attaching to it.
static bool SuspendThread(pid_t pid) {
// This may fail if the thread has just died or debugged.
@@ -81,6 +83,17 @@
return sys_ptrace(PTRACE_DETACH, pid, NULL, NULL) >= 0;
}
+inline static bool IsMappedFileOpenUnsafe(
+ const google_breakpad::MappingInfo* mapping) {
+ // It is unsafe to attempt to open a mapped file that lives under /dev,
+ // because the semantics of the open may be driver-specific so we'd risk
+ // hanging the crash dumper. And a file in /dev/ almost certainly has no
+ // ELF file identifier anyways.
+ return my_strncmp(mapping->name,
+ kMappedFileUnsafePrefix,
+ sizeof(kMappedFileUnsafePrefix) - 1) == 0;
+}
+
namespace google_breakpad {
LinuxDumper::LinuxDumper(int pid)
@@ -166,7 +179,11 @@
uint8_t identifier[sizeof(MDGUID)])
{
assert(mapping_id < mappings_.size());
+ my_memset(identifier, 0, sizeof(MDGUID));
const MappingInfo* mapping = mappings_[mapping_id];
+ if (IsMappedFileOpenUnsafe(mapping)) {
+ return false;
+ }
int fd = sys_open(mapping->name, O_RDONLY, 0);
if (fd < 0)
return false;