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 Return an error when there are too many se...



details:   https://anonhg.NetBSD.org/src/rev/1c797e62fb3b
branches:  trunk
changeset: 499661:1c797e62fb3b
user:      mycroft <mycroft%NetBSD.org@localhost>
date:      Sun Nov 26 05:22:15 2000 +0000

description:
Return an error when there are too many segments rather than abort()ing.
This way `ldd /usr/libexec/ld.elf_so' doesn't core dump.

diffstat:

 libexec/ld.elf_so/map_object.c |  21 +++++++++------------
 1 files changed, 9 insertions(+), 12 deletions(-)

diffs (44 lines):

diff -r 07e9c621244f -r 1c797e62fb3b libexec/ld.elf_so/map_object.c
--- a/libexec/ld.elf_so/map_object.c    Sun Nov 26 04:59:18 2000 +0000
+++ b/libexec/ld.elf_so/map_object.c    Sun Nov 26 05:22:15 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: map_object.c,v 1.11 2000/02/13 04:28:09 chs Exp $       */
+/*     $NetBSD: map_object.c,v 1.12 2000/11/26 05:22:15 mycroft Exp $   */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -144,15 +144,8 @@
                        break;
 
                case PT_LOAD:
-#ifdef __mips__
-                       /* NetBSD/pmax 1.1 elf toolchain peculiarity */
-                       if (nsegs >= 2) {
-                               _rtld_error("%s: too many sections\n", path);
-                               return NULL;
-                       }
-#endif
-                       assert(nsegs < 2);
-                       segs[nsegs] = phdr;
+                       if (nsegs < 2)
+                               segs[nsegs] = phdr;
                        ++nsegs;
                        break;
 
@@ -168,10 +161,14 @@
                ++phdr;
        }
        if (phdyn == NULL) {
-               _rtld_error("%s: not dynamically-linked", path);
+               _rtld_error("%s: not dynamically linked", path);
                return NULL;
        }
-       assert(nsegs == 2);
+       if (nsegs != 2) {
+               _rtld_error("%s: wrong number of segments (%d != 2)", path,
+                   nsegs);
+               return NULL;
+       }
 #ifdef __i386__
        assert(segs[0]->p_align <= PAGESIZE);
        assert(segs[1]->p_align <= PAGESIZE);



Home | Main Index | Thread Index | Old Index