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


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

PATCH: Re: A bug in the dynamic linker


On Fri, Jun 22, 2001 at 03:28:58PM -0700, H . J . Lu wrote:
> _dl_catch_error has
> 
>   /* We get here only if we longjmp'd out of OPERATE.  */
>   tsd_setspecific (old);
>   *objname = c.objname;
>   *errstring = c.errstring;
>   return errcode == -1 ? 0 : errcode;
> 
> _dl_signal_error will set the env fieldd to -1 if errcode == 0. In
> that case, _dl_catch_error will return 0. That means the error will be
>  ignore and the dynamic linker may dump core. Now the question is if
> _dl_signal_error should be called with errcode == 0 inside of
> _dl_catch_error. The one case is lose () in dl-load.c. It may call
> _dl_signal_error with errcode == 0 inside of _dl_catch_error.
> 
> 
> 

Here is a patch.


H.J.
---
2001-06-22  H.J. Lu  <hjl@gnu.org>

	* elf/dl-load.c (open_verify): Call lose () with ENOEXEC.

--- elf/dl-load.c.error	Wed May 23 17:28:52 2001
+++ elf/dl-load.c	Fri Jun 22 15:49:05 2001
@@ -1264,7 +1264,7 @@ open_verify (const char *name, struct fi
 	       (ELFMAG3 << (EI_MAG0 * 8)))
 #endif
 	      )
-	    lose (0, fd, name, NULL, NULL, N_("invalid ELF header"));
+	    lose (ENOEXEC, fd, name, NULL, NULL, N_("invalid ELF header"));
 
 	  if (ehdr->e_ident[EI_CLASS] != ELFW(CLASS))
 	    /* This is not a fatal error.  On architectures where
@@ -1275,10 +1275,10 @@ open_verify (const char *name, struct fi
 	  if (ehdr->e_ident[EI_DATA] != byteorder)
 	    {
 	      if (BYTE_ORDER == BIG_ENDIAN)
-		lose (0, fd, name, NULL, NULL,
+		lose (ENOEXEC, fd, name, NULL, NULL,
 		      "ELF file data encoding not big-endian");
 	      else
-		lose (0, fd, name, NULL, NULL,
+		lose (ENOEXEC, fd, name, NULL, NULL,
 		      "ELF file data encoding not little-endian");
 	    }
 	  if (ehdr->e_ident[EI_VERSION] != EV_CURRENT)
@@ -1287,25 +1287,25 @@ open_verify (const char *name, struct fi
 	  /* XXX We should be able so set system specific versions which are
 	     allowed here.  */
 	  if (!VALID_ELF_OSABI (ehdr->e_ident[EI_OSABI]))
-	    lose (0, fd, name, NULL, NULL, N_("ELF file OS ABI invalid"));
+	    lose (ENOEXEC, fd, name, NULL, NULL, N_("ELF file OS ABI invalid"));
 	  if (!VALID_ELF_ABIVERSION (ehdr->e_ident[EI_ABIVERSION]))
-	    lose (0, fd, name, NULL, NULL,
+	    lose (ENOEXEC, fd, name, NULL, NULL,
 		  N_("ELF file ABI version invalid"));
-	  lose (0, fd, name, NULL, NULL, N_("internal error"));
+	  lose (ENOEXEC, fd, name, NULL, NULL, N_("internal error"));
 	}
 
       if (__builtin_expect (ehdr->e_version, EV_CURRENT) != EV_CURRENT)
-	lose (0, fd, name, NULL, NULL,
+	lose (ENOEXEC, fd, name, NULL, NULL,
 	      N_("ELF file version does not match current one"));
       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)))
-	lose (0, fd, name, NULL, NULL,
+	lose (ENOEXEC, fd, name, NULL, NULL,
 	      N_("ELF file's phentsize not the expected size"));
       else if (__builtin_expect (ehdr->e_type, ET_DYN) != ET_DYN
 	       && __builtin_expect (ehdr->e_type, ET_EXEC) != ET_EXEC)
-	lose (0, fd, name, NULL, NULL,
+	lose (ENOEXEC, fd, name, NULL, NULL,
 	      N_("only ET_DYN and ET_EXEC can be loaded"));
 
       maplength = ehdr->e_phnum * sizeof (ElfW(Phdr));


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