aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornealsid <nealsid@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-05-10 20:35:54 +0000
committernealsid <nealsid@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-05-10 20:35:54 +0000
commit6bc523c6184a9c85ca1949dfc1d6636799623528 (patch)
tree64c76d27b734a3a73d7b127c8f3a8f0d4cc459b7
parentCopied minidump_test.cc from chrome_frame (see http://src.chromium.org/viewvc... (diff)
downloadbreakpad-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
-rw-r--r--src/client/linux/Makefile2
-rw-r--r--src/client/linux/crash_generation/crash_generation_client.cc3
-rw-r--r--src/client/linux/minidump_writer/linux_dumper.cc17
3 files changed, 20 insertions, 2 deletions
diff --git a/src/client/linux/Makefile b/src/client/linux/Makefile
index 53e3b0f5..5cf4baee 100644
--- a/src/client/linux/Makefile
+++ b/src/client/linux/Makefile
@@ -37,7 +37,7 @@ LIB_C_SRC = ../../common/convert_UTF.c
LIB_CC_OBJ=$(patsubst %.cc, $(OBJ_DIR)/%.o,$(LIB_CC_SRC))
LIB_C_OBJ=$(patsubst %.c, $(OBJ_DIR)/%.o, $(LIB_C_SRC))
-DUMPER_HELPER_TEST_C_SRC=minidump_writer/linux_dumper_unittest_helper.c
+DUMPER_HELPER_TEST_C_SRC=minidump_writer/linux_dumper_unittest_helper.cc
DUMPER_HELPER_TEST_C_OBJ=$(patsubst %.cc, $(OBJ_DIR)/%.o, \
$(DUMPER_HELPER_TEST_C_SRC))
diff --git a/src/client/linux/crash_generation/crash_generation_client.cc b/src/client/linux/crash_generation/crash_generation_client.cc
index af02fdbd..b05ebc58 100644
--- a/src/client/linux/crash_generation/crash_generation_client.cc
+++ b/src/client/linux/crash_generation/crash_generation_client.cc
@@ -64,7 +64,8 @@ CrashGenerationClient::RequestDump(const void* blob, size_t blob_size)
hdr->cmsg_level = SOL_SOCKET;
hdr->cmsg_type = SCM_RIGHTS;
hdr->cmsg_len = CMSG_LEN(sizeof(int));
- *((int*) CMSG_DATA(hdr)) = fds[1];
+ int* p = reinterpret_cast<int*>(CMSG_DATA(hdr));
+ *p = fds[1];
HANDLE_EINTR(sys_sendmsg(server_fd_, &msg, 0));
sys_close(fds[1]);
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;