1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-01 10:06:57 +03:00
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].
This commit is contained in:
Ulrich Drepper
2004-09-26 13:39:25 +00:00
parent 610e3e7f85
commit 625ef999a6
2 changed files with 13 additions and 1 deletions

View File

@ -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;
}