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]

[PATCH] libelf: use the right size when preading in[0].sh_size


This fixes a small thinko, that was making get_shnum to return
(size_t) -1 for all elf-64 files with e_shnum == 0.

commit 9430a51d8d7809842c651112ad30a6b56876cd89
Author: Jose E. Marchesi <jose.marchesi@oracle.com>
Date:   Tue Oct 20 16:20:39 2015 +0200

    libelf: use the right size when preading in [0].sh_size
    
    Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>

diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index d8651d7..63c7277 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,8 @@
+2015-10-20  Jose E. Marchesi  <jose.marchesi@oracle.com>
+
+	* elf_begin.c (get_shnum): Elf64_Shdr.sh_size is an Elf64_Xword.
+	Fix the size argument to pread_retry.
+
 2015-10-09  Josh Stone  <jistone@redhat.com>
 
 	* libelf.h: Replace loff_t with int64_t throughout.
diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c
index 213b5c0..11e2203 100644
--- a/libelf/elf_begin.c
+++ b/libelf/elf_begin.c
@@ -216,7 +216,7 @@ get_shnum (void *map_address, unsigned char *e_ident, int fildes, off_t offset,
 						 + offset))->sh_size,
 			sizeof (Elf64_Xword));
 	      else
-		if (unlikely (pread_retry (fildes, &size, sizeof (Elf64_Word),
+		if (unlikely (pread_retry (fildes, &size, sizeof (Elf64_Xword),
 					   offset + ehdr.e64->e_shoff
 					   + offsetof (Elf64_Shdr, sh_size))
 			      != sizeof (Elf64_Xword)))


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