diff options
author | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 2002-06-09 04:59:05 +0000 |
---|---|---|
committer | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 2002-06-09 04:59:05 +0000 |
commit | d31163030b389af2405622962aacfba806b58882 (patch) | |
tree | 80d16c33def8f8a7df0c95e067e7840c6c74ee1a /usr.bin/pmdb | |
parent | a6ebe1e65bff103e9301fdd268503dd9b117763b (diff) |
don't go further on stripped binaries; been in my tree for ever.
Diffstat (limited to 'usr.bin/pmdb')
-rw-r--r-- | usr.bin/pmdb/aout_syms.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/usr.bin/pmdb/aout_syms.c b/usr.bin/pmdb/aout_syms.c index 1092c6bfadf..aea4b3d5b97 100644 --- a/usr.bin/pmdb/aout_syms.c +++ b/usr.bin/pmdb/aout_syms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aout_syms.c,v 1.6 2002/03/29 19:32:18 deraadt Exp $ */ +/* $OpenBSD: aout_syms.c,v 1.7 2002/06/09 04:59:04 fgsch Exp $ */ /* * Copyright (c) 2002 Federico Schwindt <fgsch@openbsd.org> * All rights reserved. @@ -24,6 +24,11 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <sys/param.h> +#include <sys/ptrace.h> +#include <sys/mman.h> +#include <sys/stat.h> + #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -31,11 +36,6 @@ #include <string.h> #include <err.h> -#include <sys/param.h> -#include <sys/ptrace.h> -#include <sys/mman.h> - -#include <sys/types.h> #include <a.out.h> #include <link.h> @@ -98,6 +98,7 @@ struct sym_table * aout_open(const char *name) { struct aout_symbol_handle *ash; + struct stat sb; u_int32_t symoff, stroff; struct exec ahdr; @@ -123,6 +124,11 @@ aout_open(const char *name) goto fail; } + /* Don't go further for stripped files. */ + if (fstat(ash->ash_fd, &sb) < 0 || N_SYMOFF(ahdr) == sb.st_size || + N_STROFF(ahdr) == sb.st_size) + goto fail; + symoff = N_SYMOFF(ahdr); ash->ash_symsize = ahdr.a_syms; stroff = N_STROFF(ahdr); |