* [PATCH] libelf: use the right size when preading in[0].sh_size
@ 2015-10-20 14:22 Jose E. Marchesi
0 siblings, 0 replies; 2+ messages in thread
From: Jose E. Marchesi @ 2015-10-20 14:22 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 1388 bytes --]
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)))
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] libelf: use the right size when preading in[0].sh_size
@ 2015-10-22 21:19 Mark Wielaard
0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2015-10-22 21:19 UTC (permalink / raw)
To: elfutils-devel
[-- Attachment #1: Type: text/plain, Size: 548 bytes --]
On Tue, Oct 20, 2015 at 04:22:08PM +0200, Jose E. Marchesi wrote:
>
> This fixes a small thinko, that was making get_shnum to return
> (size_t) -1 for all elf-64 files with e_shnum == 0.
Thanks applied.
I was wondering why we didn't notice before, but that is probably because
this only happens when the file really has zero sections, wasn't mmapped
and had different endianness on a platform that doesn't allow unaligned
access. So a combination of things that is unlikely to occur on some
popular architectures.
Cheers,
Mark
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-10-22 21:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-20 14:22 [PATCH] libelf: use the right size when preading in[0].sh_size Jose E. Marchesi
2015-10-22 21:19 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).