diff options
author | Ulrich Drepper <drepper@redhat.com> | 2004-09-26 13:39:25 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2004-09-26 13:39:25 +0000 |
commit | 625ef999a6354d9c024e886919830dfda7569f44 (patch) | |
tree | a62b16835f070d7bd98700caf8f2e01b07785d21 | |
parent | 610e3e7f859b3e07dff91063ecbbdbb2f34ef4e7 (diff) | |
download | glibc-625ef999a6354d9c024e886919830dfda7569f44.zip glibc-625ef999a6354d9c024e886919830dfda7569f44.tar.gz glibc-625ef999a6354d9c024e886919830dfda7569f44.tar.bz2 |
[BZ #151]
Update.
* elf/readlib.c (process_file): Before complaining about too-short
file, check that it potentially be an ELF file. Also complain about
empty files. [BZ #151].
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | elf/readlib.c | 10 |
2 files changed, 13 insertions, 1 deletions
@@ -1,5 +1,9 @@ 2004-09-26 Ulrich Drepper <drepper@redhat.com> + * elf/readlib.c (process_file): Before complaining about too-short + file, check that it potentially be an ELF file. Also complain about + empty files. [BZ #151]. + * scripts/test-installation.pl: Fix ld.so recognition for new LD_TRACE_LOADED_OBJECTS output format. Patch by <jsberg04+computing.glibc@ftml.net> [BZ #407]. diff --git a/elf/readlib.c b/elf/readlib.c index a1fec94..4fbc3e5 100644 --- a/elf/readlib.c +++ b/elf/readlib.c @@ -105,7 +105,15 @@ process_file (const char *real_file_name, const char *file_name, if ((size_t) statbuf.st_size < sizeof (struct exec) || (size_t) statbuf.st_size < sizeof (ElfW(Ehdr))) { - error (0, 0, _("File %s is too small, not checked."), file_name); + if (statbuf.st_size == 0) + error (0, 0, _("File %s is empty, not checked."), file_name); + else + { + char buf[SELFMAG]; + size_t n = MIN (statbuf.st_size, SELFMAG); + if (fread (buf, n, 1, file) == 1 && memcmp (buf, ELFMAG, n) == 0) + error (0, 0, _("File %s is too small, not checked."), file_name); + } fclose (file); return 1; } |