From ae5193c24ee046c5b8197ce76838a2b2c0e05e01 Mon Sep 17 00:00:00 2001 From: "benchan@chromium.org" Date: Wed, 21 Dec 2011 17:51:40 +0000 Subject: Replace readlink calls with a safer version that guarantees NULL-termination. This patch is part of a bigger patch that helps merging the breakpad code with the modified version in Chromium OS. Specifically, this patch makes the following changes: 1. Add a SafeReadLink function that wraps sys_readlink() to resolve a symbolic link but guarantees the result is NULL-terminated on success. 2. Refactor other source code to use SafeReadLink instead of readlink() or sys_readlink(). BUG=455 TEST=Tested the following: 1. Build on 32-bit and 64-bit Linux with gcc 4.4.3 and gcc 4.6. 2. Build on Mac OS X 10.6.8 with gcc 4.2 and clang 3.0 (with latest gmock). 3. All unit tests pass. 4. Run minidump-2-core to covnert a minidump file to a core file. Review URL: http://breakpad.appspot.com/334001 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@896 4c0a9323-5329-0410-9bdc-e9ce6186880e --- Makefile.am | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Makefile.am') diff --git a/Makefile.am b/Makefile.am index 61921602..47e7676f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -73,7 +73,8 @@ src_client_linux_libbreakpad_client_a_SOURCES = \ src/common/string_conversion.cc \ src/common/linux/file_id.cc \ src/common/linux/guid_creator.cc \ - src/common/linux/memory_mapped_file.cc + src/common/linux/memory_mapped_file.cc \ + src/common/linux/safe_readlink.cc endif LINUX_HOST if !DISABLE_PROCESSOR @@ -314,6 +315,7 @@ src_client_linux_linux_client_unittest_LDADD = \ src/common/linux/file_id.o \ src/common/linux/guid_creator.o \ src/common/linux/memory_mapped_file.o \ + src/common/linux/safe_readlink.o \ src/common/string_conversion.o src_client_linux_linux_client_unittest_DEPENDENCIES = src/client/linux/linux_dumper_unittest_helper src/client/linux/libbreakpad_client.a src/libbreakpad.a @@ -334,6 +336,7 @@ src_tools_linux_dump_syms_dump_syms_SOURCES = \ src/common/linux/elf_symbols_to_module.cc \ src/common/linux/file_id.cc \ src/common/linux/memory_mapped_file.cc \ + src/common/linux/safe_readlink.cc \ src/tools/linux/dump_syms/dump_syms.cc src_tools_linux_md2core_minidump_2_core_SOURCES = \ @@ -384,6 +387,8 @@ src_common_dumper_unittest_SOURCES = \ src/common/linux/synth_elf_unittest.cc \ src/common/linux/file_id.cc \ src/common/linux/file_id_unittest.cc \ + src/common/linux/safe_readlink.cc \ + src/common/linux/safe_readlink_unittest.cc \ src/testing/gtest/src/gtest-all.cc \ src/testing/gtest/src/gtest_main.cc \ src/testing/src/gmock-all.cc -- cgit v1.2.1