summaryrefslogtreecommitdiff
path: root/libelf/elf_strptr.c
Commit message (Collapse)AuthorAgeFilesLines
* libelf: Optimize elf_strptr.c validate_str by checking last char firstMark Wielaard2021-07-191-1/+3
| | | | | | | | | | | In most cases the last char of the sectio will be zero. Check that first before calling memrchr. This is a minor optimization in normal cases. But it helps asan a lot by removing the memrchr call in most cases. https://sourceware.org/bugzilla/show_bug.cgi?id=28101 Signed-off-by: Mark Wielaard <mark@klomp.org>
* libelf: Check header exists in elf_strptrMark Wielaard2020-11-061-1/+1
| | | | | | | | We already checked the header actually existed for ELFCLASS64 but not for the ELFCLASS32 case. It is very unlikely it is at this point in the code, but theoretically it could happen. Signed-off-by: Mark Wielaard <mark@klomp.org>
* libelf: Check for NULL shdr in elf_strptr.Mark Wielaard2020-05-141-1/+1
| | | | | | | | GCC10 -fanalyzer with -flto notices __elf64_getshdr_rdlock can fail and because the result isn't checked in elf_strptr it can cause a dereference of NULL. Signed-off-by: Mark Wielaard <mark@klomp.org>
* Do not depend on some non-POSIX features.Akihiko Odaki2016-10-131-8/+22
| | | | | | | | Define/open code memrchr, rawmemchr, powerof2 and TEMP_FAILURE_RETRY if not available through system headers. Signed-off-by: Akihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp> Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Move nested functions in elf_compress.c and elf_strptr.c.Chih-Hung Hsieh2016-01-231-16/+17
| | | | | | | * elf_compress.c (__libelf_compress): do_deflate_cleanup * elf_strptr.c (elf_strptr): get_zdata Signed-off-by: Chih-Hung Hsieh <chh@google.com>
* libelf: Make elf_strptr index correctly into compressed section data.Mark Wielaard2016-01-061-5/+45
| | | | | | | | | elf_strptr indexes into the section data. This is defined as index into the uncompressed data of the section. If the section is compressed make sure the uncompressed data is available, but don't really decompress the section header (elf_getdata will still return compressed data). Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Remove old-style function definitions.Mark Wielaard2015-09-231-4/+1
| | | | | | | We already require -std=gnu99 and old-style function definitions might hide some compiler warnings. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libelf: Make sure string returned by elf_strptr is NUL terminated.Mark Wielaard2015-02-061-2/+21
| | | | | | | | | | The result of elf_strptr is often used directly to print or strcmp the string. If the section data was truncated or corrupted that could lead to invalid memory reads possibly crashing the application. https://bugzilla.redhat.com/show_bug.cgi?id=1170810#c24 Reported-by: Alexander Cherepanov <cherepan@mccme.ru> Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libelf: elf_strptr should use datalist when data has been added to section.Mark Wielaard2015-02-061-6/+12
| | | | | | | | | | elf_strptr always used the rawdata when available. But when data has been added to the section it should find the correct buffer in the datalist. Adds a large testcase that checks various ways of adding and extracting strings from a section. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* libelf: elf_strptr should fetch the shdr for the section if not yet known.Mark Wielaard2015-02-061-5/+7
| | | | | | | | | elf_strptr might be called before the shdrs are read in. In that case it needs to explicitly call __elf[32|64]_getshdr_rdlock to check the section type and size. The new strptr testcase triggers this corner case and crashes before the fix. Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Update name, license and contributor policy.Mark Wielaard2012-06-051-40/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Change name from "Red Hat elfutils" to "elfutils". * Update license of standalone tools and test from GPLv2 to GPLv3+. * Change license of libraries from GPLv2+exception to GPLv2/LGPLv3+. * Add Developer Certificate of Origin based contributor policy. top-level: - COPYING: Upgraded from GPLv2 to GPLv3. - CONTRIBUTING, COPYING-GPLv2, COPYING-LGPLv3: New files. - NEWS: Added note about new contribution and license policy. - Makefile.am: Updated to GPLv3, added new files to EXTRA_DIST. - configure.ac: Update to GPLv3, changed AC_INIT name to 'elfutils'. backends, lib, libasm, libcpu, libdw, libdwfl, libebl, libelf: - All files updated to GPLv2/LGPLv3+. Except some very small files (<5 lines) which didn't have any headers at all before, the linker .maps files and the libcpu/defs files which only contain data and libelf/elf.h which comes from glibc and is under LGPLv2+. config: - elfutils.spec.in: Add new License: headers and new %doc files. - Update all license headers to GPLv2/LGPLv3+ for files used by libs. src, tests: - All files updated to GPLv3+. Except for the test bz2 data files, the linker maps and script files and some very small files (<5 lines) that don't have any headers. Signed-off-by: Richard Fontana <rfontana@redhat.com> Signed-off-by: Mark Wielaard <mjw@redhat.com>
* Document possible elf_strptr problem.Ulrich Drepper2009-02-011-1/+5
|
* Fix up bogon and missing log entries from .pmachata.threads branch.Roland McGrath2008-08-251-6/+11
|
* propagate from branch 'com.redhat.elfutils.pmachata.threads' (head ↵Ulrich Drepper2008-08-161-3/+3
| | | | | | 8bd3bc10eb015c96f7bafcc6a22c973620b57dd8) to branch 'com.redhat.elfutils' (head c5a11b6b3329382f1b5ffd0020f0d93c64176f20)
* Implement --build-id command line parameter for ld.Ulrich Drepper2008-01-311-3/+21
|
* Fix FSF address. No exception for libdwarf.Ulrich Drepper2006-04-041-1/+1
|
* propagate from branch 'com.redhat.elfutils.roland.pending' (head ↵Ulrich Drepper2006-04-041-12/+45
| | | | | | 4f8fc821345feef58624f0aa5b470d4827577d8c) to branch 'com.redhat.elfutils' (head 76e26cb54695fd3b21ee8fb5be3036bd68200633)
* Adjust for monotone.Ulrich Drepper2005-07-261-0/+122