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
This commit is contained in:
nealsid 2010-05-10 20:35:54 +00:00
parent 297b1e5a06
commit 6bc523c618
3 changed files with 20 additions and 2 deletions

View File

@ -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))

View File

@ -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]);

View File

@ -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;