[PATCH] Improve dlopen error reporting
Jakub Jelinek
jakub@redhat.com
Fri Apr 30 14:01:00 GMT 2004
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
More information about the Libc-hacker
mailing list