summaryrefslogtreecommitdiff
path: root/elf/readlib.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2004-09-27 06:18:18 +0000
committerJakub Jelinek <jakub@redhat.com>2004-09-27 06:18:18 +0000
commitf1750fb9c68854778e6e023ed490ff80e1c90167 (patch)
tree416f6a0fabb42abbdafde8965810adb5abcf0283 /elf/readlib.c
parentefaf80c5d05102f75864847140bfb8b2bdbd4523 (diff)
Updated to fedora-glibc-20040927T0611cvs/fedora-glibc-2_3_3-59
Diffstat (limited to 'elf/readlib.c')
-rw-r--r--elf/readlib.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/elf/readlib.c b/elf/readlib.c
index a1fec94589..4fbc3e5e4c 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;
}