This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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] Improve dlopen error reporting


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


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