This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[COMMITTED] libasm: Check return value of gelf_update_ehdr in asm_end.


In theory the gelf_update_ehdr call could fail. Immediately report an
error in that case.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 libasm/ChangeLog | 4 ++++
 libasm/asm_end.c | 6 +++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/libasm/ChangeLog b/libasm/ChangeLog
index 92dfd72..05b830c 100644
--- a/libasm/ChangeLog
+++ b/libasm/ChangeLog
@@ -1,3 +1,7 @@
+2019-03-06  Mark Wielaard  <mark@klomp.org>
+
+	* asm_end.c (binary_end): Check return value of gelf_update_ehdr.
+
 2018-10-19  Mark Wielaard  <mark@klomp.org>
 
 	* disasm_cb.c (read_symtab_exec): Check sh_entsize is not zero.
diff --git a/libasm/asm_end.c b/libasm/asm_end.c
index 5aab8df..99e9501 100644
--- a/libasm/asm_end.c
+++ b/libasm/asm_end.c
@@ -460,7 +460,11 @@ binary_end (AsmCtx_t *ctx)
   else
     ehdr->e_shstrndx = elf_ndxscn (shstrscn);
 
-  gelf_update_ehdr (ctx->out.elf, ehdr);
+  if (unlikely (gelf_update_ehdr (ctx->out.elf, ehdr) == 0))
+    {
+      __libasm_seterrno (ASM_E_LIBELF);
+      result = -1;
+    }
 
   /* Write out the ELF file.  */
   if (unlikely (elf_update (ctx->out.elf, ELF_C_WRITE_MMAP) < 0))
-- 
1.8.3.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]