public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Improve dlopen error reporting
@ 2004-04-30 14:01 Jakub Jelinek
  2004-05-03 21:24 ` Ulrich Drepper
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2004-04-30 14:01 UTC (permalink / raw)
  To: Ulrich Drepper, Roland McGrath; +Cc: Glibc hackers

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Improve dlopen error reporting
  2004-04-30 14:01 [PATCH] Improve dlopen error reporting Jakub Jelinek
@ 2004-05-03 21:24 ` Ulrich Drepper
  0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Drepper @ 2004-05-03 21:24 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Glibc hackers

Applied.

-- 
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-05-03 21:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-30 14:01 [PATCH] Improve dlopen error reporting Jakub Jelinek
2004-05-03 21:24 ` Ulrich Drepper

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).