From e7c036b39ef12abc7ff131982df75e3ec35c0f31 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 11 Apr 2000 16:27:38 +0000 Subject: Update. 2000-04-11 Ulrich Drepper * posix/globtest.sh: Fix last change. 2000-04-10 Philip Blundell * sysdeps/unix/sysv/linux/bits/in.h (IPV6_JOIN_GROUP, IPV6_LEAVE_GROUP): New names for IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP. * sysdeps/generic/bits/in.h (IPV6_JOIN_GROUP, IPV6_LEAVE_GROUP): Likewise. 2000-04-11 Ulrich Drepper * elf/readlib (process_file): Close streams in case of an error. 2000-04-09 Andreas Jaeger * elf/readlib.c (process_file): Check if file is big enough to contain aout and ELF headers. Reported by Reinhard Moosauer . 2000-04-10 Jes Sorensen * elf/dl-fini.c: Include alloca.h to get proper prototype for alloca(). 2000-04-11 Ulrich Drepper * test-skeleton.c (main): If STDOUT_UNBUFFERED is defined, make stdout stream unbuffered. * rt/Makefile (tests): Add tst-clock. Add rules to build tst-clock. * rt/tst-clock.c: New file. * sysdeps/unix/i386/i586/clock_getres.c: Correct expression to decide about initialization of nsec. * sysdeps/unix/i386/i586/clock_gettime.c: Correct expression to decide about initialization of freq. Set retval to zero if successful. * sysdeps/unix/sysv/linux/i386/get_clockfreq.c: Cache result. --- elf/dl-fini.c | 1 + elf/readlib.c | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'elf') diff --git a/elf/dl-fini.c b/elf/dl-fini.c index fd22bc0..a285c77 100644 --- a/elf/dl-fini.c +++ b/elf/dl-fini.c @@ -17,6 +17,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include #include #include diff --git a/elf/readlib.c b/elf/readlib.c index abd380b..580d802 100644 --- a/elf/readlib.c +++ b/elf/readlib.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1999 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Andreas Jaeger , 1999 and Jakub Jelinek , 1999. @@ -92,10 +92,22 @@ process_file (const char *file_name, const char *lib, int *flag, char **soname, if (fstat (fileno (file), &statbuf) < 0) { error (0, 0, _("Cannot fstat file %s.\n"), file_name); + fclose (file); + return 1; + } + + /* Check that the file is large enough so that we can access the + information. We're only checking the size of the headers here. */ + if (statbuf.st_size < sizeof (struct exec) + || statbuf.st_size < sizeof (ElfW(Ehdr))) + { + error (0, 0, _("File %s is too small, not checked."), file_name); + fclose (file); return 1; } - file_contents = mmap (0, statbuf.st_size, PROT_READ, MAP_SHARED, fileno (file), 0); + file_contents = mmap (0, statbuf.st_size, PROT_READ, MAP_SHARED, + fileno (file), 0); if (file_contents == MAP_FAILED) { error (0, 0, _("Cannot mmap file %s.\n"), file_name); @@ -108,7 +120,7 @@ process_file (const char *file_name, const char *lib, int *flag, char **soname, if (N_MAGIC (*aout_header) == ZMAGIC || N_MAGIC (*aout_header) == QMAGIC) { - /* Aout files don't have a soname, just return the the name + /* Aout files don't have a soname, just return the name including the major number. */ char *copy, *major, *dot; copy = xstrdup (lib); -- cgit v1.1