diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2007-04-18 19:03:05 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2007-04-18 19:03:05 +0000 |
commit | e76f2185f9a62f9dc922d0f8ae1571c64c2d887d (patch) | |
tree | 75da6612f2a61a60eae604e1a6308136fb4cb400 /usr.bin/nm/elf.c | |
parent | 2ec25a2d99ef9124dd51909b5bc2db099cdb50a9 (diff) |
Fix a NULL dereference if the symbol table size is zero; ok millert@ deraadt@
Diffstat (limited to 'usr.bin/nm/elf.c')
-rw-r--r-- | usr.bin/nm/elf.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/usr.bin/nm/elf.c b/usr.bin/nm/elf.c index a6c8f04ff1f..17559bbb44b 100644 --- a/usr.bin/nm/elf.c +++ b/usr.bin/nm/elf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: elf.c,v 1.16 2007/02/08 03:50:49 ray Exp $ */ +/* $OpenBSD: elf.c,v 1.17 2007/04/18 19:03:04 miod Exp $ */ /* * Copyright (c) 2003 Michael Shalayeff @@ -27,7 +27,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: elf.c,v 1.16 2007/02/08 03:50:49 ray Exp $"; +static const char rcsid[] = "$OpenBSD: elf.c,v 1.17 2007/04/18 19:03:04 miod Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -518,6 +518,11 @@ elf_symload(const char *name, FILE *fp, off_t foff, Elf_Ehdr *eh, char *shstr; shstrsize = shdr[eh->e_shstrndx].sh_size; + if (shstrsize == 0) { + warnx("%s: no name list", name); + return (1); + } + if ((shstr = malloc(shstrsize)) == NULL) { warn("%s: malloc shsrt", name); return (1); |