summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormiod <miod@openbsd.org>2007-04-18 19:03:04 +0000
committermiod <miod@openbsd.org>2007-04-18 19:03:04 +0000
commit44579ce9365606a43bb32c5794ef71c31c0325bf (patch)
treeed4b06d36230947699e1e59322bfcddb32dc7081
parentReserve a few pg_flags for pmaps that might want to use them. (diff)
downloadwireguard-openbsd-44579ce9365606a43bb32c5794ef71c31c0325bf.tar.xz
wireguard-openbsd-44579ce9365606a43bb32c5794ef71c31c0325bf.zip
Fix a NULL dereference if the symbol table size is zero; ok millert@ deraadt@
-rw-r--r--usr.bin/nm/elf.c9
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);