From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21986 invoked by alias); 30 Apr 2004 14:01:09 -0000 Mailing-List: contact libc-hacker-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sources.redhat.com Received: (qmail 21964 invoked from network); 30 Apr 2004 14:01:08 -0000 Received: from unknown (HELO sunsite.ms.mff.cuni.cz) (195.113.15.26) by sources.redhat.com with SMTP; 30 Apr 2004 14:01:08 -0000 Received: from sunsite.ms.mff.cuni.cz (sunsite.mff.cuni.cz [127.0.0.1]) by sunsite.ms.mff.cuni.cz (8.12.8/8.12.8) with ESMTP id i3UBn13j002738; Fri, 30 Apr 2004 13:49:02 +0200 Received: (from jakub@localhost) by sunsite.ms.mff.cuni.cz (8.12.8/8.12.8/Submit) id i3UBn0Z5002708; Fri, 30 Apr 2004 13:49:00 +0200 Date: Fri, 30 Apr 2004 14:01:00 -0000 From: Jakub Jelinek To: Ulrich Drepper , Roland McGrath Cc: Glibc hackers Subject: [PATCH] Improve dlopen error reporting Message-ID: <20040430114859.GY5191@sunsite.ms.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4i X-SW-Source: 2004-04/txt/msg00102.txt.bz2 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 * 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