mirror of
https://github.com/openbsd/src.git
synced 2025-01-03 06:45:37 -08:00
add some check before accessing data:
- if section header table is be present - consistency of section header table size ok miod@
This commit is contained in:
parent
f47663ad1a
commit
642c3e06fd
@ -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
|
||||
@ -149,6 +149,16 @@ elf_load_shdrs(const char *name, FILE *fp, off_t foff, Elf_Ehdr *head)
|
||||
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user