diff options
author | Roland McGrath <roland@hack.frob.com> | 2012-03-28 10:22:35 -0700 |
---|---|---|
committer | Roland McGrath <roland@hack.frob.com> | 2012-03-28 10:22:35 -0700 |
commit | 210c2f03efbbaacc51f2641baa0947d9c316de12 (patch) | |
tree | 519c155c5d784470434c4d1d647d6f9fdc2201cf | |
parent | 8e8f0be57354d3fa094d0927930dbe1bc1ce8816 (diff) | |
download | elfutils-210c2f03efbbaacc51f2641baa0947d9c316de12.tar.gz |
RHBZ#805447: Fix core file grokking for case of truncated .dynstr
-rw-r--r-- | libdwfl/ChangeLog | 7 | ||||
-rw-r--r-- | libdwfl/dwfl_segment_report_module.c | 8 |
2 files changed, 13 insertions, 2 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 87a05550..86f6fba4 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,10 @@ +2012-03-28 Roland McGrath <roland@hack.frob.com> + + * dwfl_segment_report_module.c + (dwfl_segment_report_module: read_portion): Don't use existing buffer + when FILESZ is zero (string mode) and available portion doesn't hold + a terminated string. + 2011-12-02 Roland McGrath <roland@hack.frob.com> * elf-from-memory.c (elf_from_remote_memory): Fix ELFCLASS64 case diff --git a/libdwfl/dwfl_segment_report_module.c b/libdwfl/dwfl_segment_report_module.c index 012a0fde..55341804 100644 --- a/libdwfl/dwfl_segment_report_module.c +++ b/libdwfl/dwfl_segment_report_module.c @@ -1,5 +1,5 @@ /* Sniff out modules from ELF headers visible in memory segments. - Copyright (C) 2008-2010 Red Hat, Inc. + Copyright (C) 2008-2012 Red Hat, Inc. This file is part of Red Hat elfutils. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -155,7 +155,11 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name, inline bool read_portion (void **data, size_t *data_size, GElf_Addr vaddr, size_t filesz) { - if (vaddr - start + filesz > buffer_available) + if (vaddr - start + filesz > buffer_available + /* If we're in string mode, then don't consider the buffer we have + sufficient unless it contains the terminator of the string. */ + || (filesz == 0 && memchr (vaddr - start + buffer, '\0', + buffer_available - (vaddr - start)) == NULL)) { *data = NULL; *data_size = filesz; |