Skip to content

Commit

Permalink
[BZ #151]
Browse files Browse the repository at this point in the history
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].
  • Loading branch information
Ulrich Drepper committed Sep 26, 2004
1 parent 610e3e7 commit 625ef99
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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].
Expand Down
10 changes: 9 additions & 1 deletion elf/readlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 625ef99

Please sign in to comment.