-/* $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
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);
return (NULL);