diff options
author | Yabin Cui <yabinc@google.com> | 2015-04-14 21:02:02 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-04-14 21:02:02 +0000 |
commit | 5966e7e5f4a7d79986dbea3415f29a595b259877 (patch) | |
tree | d67d74604d3df66d930269b06add44f7780ea385 | |
parent | d65b1281f43660b9405d050ccfddb946fc6e10a2 (diff) | |
parent | 03e590a7285111b2f8ef25dac74e50a543ed8010 (diff) | |
download | system_core-5966e7e5f4a7d79986dbea3415f29a595b259877.zip system_core-5966e7e5f4a7d79986dbea3415f29a595b259877.tar.gz system_core-5966e7e5f4a7d79986dbea3415f29a595b259877.tar.bz2 |
am 03e590a7: am 7369d314: Merge "Fix alignment when reading note segment."
* commit '03e590a7285111b2f8ef25dac74e50a543ed8010':
Fix alignment when reading note segment.
-rw-r--r-- | debuggerd/elf_utils.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/debuggerd/elf_utils.cpp b/debuggerd/elf_utils.cpp index 764b9db..5ea03e7 100644 --- a/debuggerd/elf_utils.cpp +++ b/debuggerd/elf_utils.cpp @@ -29,6 +29,8 @@ #include "elf_utils.h" +#define NOTE_ALIGN(size) ((size + 3) & ~3) + template <typename HdrType, typename PhdrType, typename NhdrType> static bool get_build_id( Backtrace* backtrace, uintptr_t base_addr, uint8_t* e_ident, std::string* build_id) { @@ -60,7 +62,7 @@ static bool get_build_id( addr += sizeof(nhdr); if (nhdr.n_type == NT_GNU_BUILD_ID) { // Skip the name (which is the owner and should be "GNU"). - addr += nhdr.n_namesz; + addr += NOTE_ALIGN(nhdr.n_namesz); uint8_t build_id_data[128]; if (nhdr.n_namesz > sizeof(build_id_data)) { ALOGE("Possible corrupted note, name size value is too large: %u", @@ -80,7 +82,7 @@ static bool get_build_id( } else { // Move past the extra note data. hdr_size -= sizeof(nhdr); - size_t skip_bytes = nhdr.n_namesz + nhdr.n_descsz; + size_t skip_bytes = NOTE_ALIGN(nhdr.n_namesz) + NOTE_ALIGN(nhdr.n_descsz); addr += skip_bytes; if (hdr_size < skip_bytes) { break; |