From: Jakub Jelinek <jakub@redhat.com>
To: Ulrich Drepper <drepper@redhat.com>, Roland McGrath <roland@redhat.com>
Cc: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: [PATCH] Improve dlopen error reporting
Date: Fri, 30 Apr 2004 14:01:00 -0000 [thread overview]
Message-ID: <20040430114859.GY5191@sunsite.ms.mff.cuni.cz> (raw)
Hi!
If somebody attempts to dlopen an ET_REL object, the error reported is
ELF file's phentsize not the expected size
and not
only ET_DYN and ET_EXEC can be loaded
because of the order of error checks. ET_REL files usually have e_phentsize
0, but complaining about that instead of the type of object can be quite
confusing to the users.
The following patch reorders the checks.
2004-04-30 Jakub Jelinek <jakub@redhat.com>
* elf/dl-load.c (open_verify): Move e_phentsize check after e_type
check.
--- libc/elf/dl-load.c.jj 2004-04-13 10:42:51.000000000 +0200
+++ libc/elf/dl-load.c 2004-04-30 15:56:42.112183953 +0200
@@ -1520,18 +1520,18 @@ open_verify (const char *name, struct fi
}
if (! __builtin_expect (elf_machine_matches_host (ehdr), 1))
goto close_and_out;
- else if (__builtin_expect (ehdr->e_phentsize, sizeof (ElfW(Phdr)))
- != sizeof (ElfW(Phdr)))
- {
- errstring = N_("ELF file's phentsize not the expected size");
- goto call_lose;
- }
else if (__builtin_expect (ehdr->e_type, ET_DYN) != ET_DYN
&& __builtin_expect (ehdr->e_type, ET_EXEC) != ET_EXEC)
{
errstring = N_("only ET_DYN and ET_EXEC can be loaded");
goto call_lose;
}
+ else if (__builtin_expect (ehdr->e_phentsize, sizeof (ElfW(Phdr)))
+ != sizeof (ElfW(Phdr)))
+ {
+ errstring = N_("ELF file's phentsize not the expected size");
+ goto call_lose;
+ }
maplength = ehdr->e_phnum * sizeof (ElfW(Phdr));
if (ehdr->e_phoff + maplength <= (size_t) fbp->len)
Jakub
next reply other threads:[~2004-04-30 14:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-30 14:01 Jakub Jelinek [this message]
2004-05-03 21:24 ` Ulrich Drepper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040430114859.GY5191@sunsite.ms.mff.cuni.cz \
--to=jakub@redhat.com \
--cc=drepper@redhat.com \
--cc=libc-hacker@sources.redhat.com \
--cc=roland@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).