diff options
author | nealsid <nealsid@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2010-05-10 20:35:54 +0000 |
---|---|---|
committer | nealsid <nealsid@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2010-05-10 20:35:54 +0000 |
commit | 6bc523c6184a9c85ca1949dfc1d6636799623528 (patch) | |
tree | 64c76d27b734a3a73d7b127c8f3a8f0d4cc459b7 /src/client/linux/minidump_writer/linux_dumper.cc | |
parent | Copied minidump_test.cc from chrome_frame (see http://src.chromium.org/viewvc... (diff) | |
download | breakpad-6bc523c6184a9c85ca1949dfc1d6636799623528.tar.xz |
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
Diffstat (limited to 'src/client/linux/minidump_writer/linux_dumper.cc')
-rw-r--r-- | src/client/linux/minidump_writer/linux_dumper.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/client/linux/minidump_writer/linux_dumper.cc b/src/client/linux/minidump_writer/linux_dumper.cc index be199f7b..c693e907 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 @@ static bool ResumeThread(pid_t pid) { 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 @@ LinuxDumper::ElfFileIdentifierForMapping(unsigned int mapping_id, 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; |