Source-Changes-HG archive

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

[src/trunk]: src/sys/ddb Extra sanity checking on ELF headers: Make sure the...



details:   https://anonhg.NetBSD.org/src/rev/1910c38e9bfd
branches:  trunk
changeset: 513451:1910c38e9bfd
user:      bjh21 <bjh21%NetBSD.org@localhost>
date:      Tue Jul 31 22:31:47 2001 +0000

description:
Extra sanity checking on ELF headers:  Make sure the bootloader actually
loaded (or claims to have loaded) everything we need.

diffstat:

 sys/ddb/db_elf.c |  8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diffs (32 lines):

diff -r 9f50f429bf2c -r 1910c38e9bfd sys/ddb/db_elf.c
--- a/sys/ddb/db_elf.c  Tue Jul 31 22:30:07 2001 +0000
+++ b/sys/ddb/db_elf.c  Tue Jul 31 22:31:47 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_elf.c,v 1.15 2001/07/31 19:14:18 bjh21 Exp $        */
+/*     $NetBSD: db_elf.c,v 1.16 2001/07/31 22:31:47 bjh21 Exp $        */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -150,9 +150,13 @@
         * Find the first (and, we hope, only) SHT_SYMTAB section in
         * the file, and the SHT_STRTAB section that goes with it.
         */
+       if (elf->e_shoff == 0)
+               goto badheader;
        shp = (Elf_Shdr *)((char *)symtab + elf->e_shoff);
        for (i = 0; i < elf->e_shnum; i++) {
                if (shp[i].sh_type == SHT_SYMTAB) {
+                       if (shp[i].sh_offset == 0)
+                               continue;
                        /* Got the symbol table. */
                        symtab_start = (Elf_Sym *)((char *)symtab + 
                            shp[i].sh_offset);
@@ -160,6 +164,8 @@
                            shp[i].sh_offset + shp[i].sh_size);
                        /* Find the string table to go with it. */
                        j = shp[i].sh_link;
+                       if (shp[j].sh_offset == 0)
+                               continue;
                        strtab_start = (char *)symtab + shp[j].sh_offset;
                        strtab_end = (char *)symtab + shp[j].sh_offset +
                            shp[j].sh_size;



Home | Main Index | Thread Index | Old Index