Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/libexec/ld.elf_so If fstat info was passed, and from it it c...



details:   https://anonhg.NetBSD.org/src/rev/124c9773391e
branches:  trunk
changeset: 542770:124c9773391e
user:      fvdl <fvdl%NetBSD.org@localhost>
date:      Thu Feb 06 12:38:17 2003 +0000

description:
If fstat info was passed, and from it it can be seen that the file size
is smaller than an ELF header, don't even bother to try to look at it.
Avoids coredumps with zero-sized files.

diffstat:

 libexec/ld.elf_so/map_object.c |  7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diffs (21 lines):

diff -r 56eaec780a09 -r 124c9773391e libexec/ld.elf_so/map_object.c
--- a/libexec/ld.elf_so/map_object.c    Thu Feb 06 12:21:21 2003 +0000
+++ b/libexec/ld.elf_so/map_object.c    Thu Feb 06 12:38:17 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: map_object.c,v 1.25 2002/12/05 04:56:57 junyoung Exp $  */
+/*     $NetBSD: map_object.c,v 1.26 2003/02/06 12:38:17 fvdl Exp $      */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -85,6 +85,11 @@
        size_t           nclear;
 #endif
 
+       if (sb != NULL && sb->st_size < sizeof (Elf_Ehdr)) {
+               _rtld_error("%s: unrecognized file format", path);
+               return NULL;
+       }
+
        obj = _rtld_obj_new();
        obj->path = path;
        obj->pathlen = strlen(path);



Home | Main Index | Thread Index | Old Index