public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [COMMITTED] unstrip: Robustify gelf_getshdr and gelf_getsymshndx calls.
@ 2019-04-28 16:08 Mark Wielaard
  0 siblings, 0 replies; only message in thread
From: Mark Wielaard @ 2019-04-28 16:08 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Mark Wielaard

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 src/ChangeLog | 6 ++++++
 src/unstrip.c | 4 ++++
 2 files changed, 10 insertions(+)

diff --git a/src/ChangeLog b/src/ChangeLog
index e3e411ef5..ae1379327 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2019-04-28  Mark Wielaard  <mark@klomp.org>
+
+	* unstrip.c (add_new_section_symbols): Call ELF_CHECK after
+	gelf_getsymshndx.
+	(new_shstrtab): Call ELF_CHECK after gelf_getshdr.
+
 2019-04-28  Mark Wielaard  <mark@klomp.org>
 
 	* size.c (show_sysv): Call INTERNAL_ERROR if gelf_getshdr
diff --git a/src/unstrip.c b/src/unstrip.c
index 3495b1d91..fc8783255 100644
--- a/src/unstrip.c
+++ b/src/unstrip.c
@@ -644,6 +644,7 @@ add_new_section_symbols (Elf_Scn *old_symscn, size_t old_shnum,
       GElf_Word shndx = SHN_UNDEF;
       GElf_Sym *sym = gelf_getsymshndx (old_symdata, shndxdata,
 					i, &sym_mem, &shndx);
+      ELF_CHECK (sym != NULL, _("cannot get symbol table entry: %s"));
       ELF_CHECK (gelf_update_symshndx (symdata, shndxdata, i,
 				       sym, shndx),
 		 _("cannot update symbol table: %s"));
@@ -677,6 +678,7 @@ add_new_section_symbols (Elf_Scn *old_symscn, size_t old_shnum,
       GElf_Word shndx = SHN_UNDEF;
       GElf_Sym *sym = gelf_getsymshndx (old_symdata, shndxdata,
 					i, &sym_mem, &shndx);
+      ELF_CHECK (sym != NULL, _("cannot get symbol table entry: %s"));
       ELF_CHECK (gelf_update_symshndx (symdata, shndxdata,
 				       i + added, sym, shndx),
 		 _("cannot update symbol table: %s"));
@@ -1326,6 +1328,7 @@ new_shstrtab (Elf *unstripped, size_t unstripped_shnum,
 	Elf_Scn *scn = elf_getscn (unstripped, i + 1);
 	GElf_Shdr shdr_mem;
 	GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
+	ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
 	const char *name = get_section_name (i + 1, shdr, shstrtab);
 	unstripped_strent[i] = dwelf_strtab_add (strtab, name);
 	ELF_CHECK (unstripped_strent[i] != NULL,
@@ -1349,6 +1352,7 @@ new_shstrtab (Elf *unstripped, size_t unstripped_shnum,
 	Elf_Scn *scn = elf_getscn (unstripped, i + 1);
 	GElf_Shdr shdr_mem;
 	GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
+	ELF_CHECK (shdr != NULL, _("cannot get section header: %s"));
 	shdr->sh_name = dwelf_strent_off (unstripped_strent[i]);
 	if (i + 1 == unstripped_shstrndx)
 	  shdr->sh_size = strtab_data->d_size;
-- 
2.20.1

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-04-28 16:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-28 16:08 [COMMITTED] unstrip: Robustify gelf_getshdr and gelf_getsymshndx calls Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).