=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/nm/elf.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- src/usr.bin/nm/elf.c 2015/05/17 20:19:08 1.28 +++ src/usr.bin/nm/elf.c 2015/06/23 13:43:08 1.29 @@ -1,4 +1,4 @@ -/* $OpenBSD: elf.c,v 1.28 2015/05/17 20:19:08 guenther Exp $ */ +/* $OpenBSD: elf.c,v 1.29 2015/06/23 13:43:08 semarie Exp $ */ /* * Copyright (c) 2003 Michael Shalayeff @@ -148,6 +148,16 @@ Elf_Shdr *shdr; elf_fix_header(head); + + if (head->e_shnum == 0) { + warnx("%s: no section header table", name); + return (NULL); + } + + if (head->e_shstrndx >= head->e_shnum) { + warnx("%s: inconsistent section header table", name); + return (NULL); + } if ((shdr = calloc(head->e_shentsize, head->e_shnum)) == NULL) { warn("%s: malloc shdr", name);