From 0025247171cff79fc955f70ed127a3de49c68d28 Mon Sep 17 00:00:00 2001 From: Damien Zammit Date: Sun, 3 Sep 2017 21:04:41 +1000 Subject: rmodtool: Increase limit on number of symbols MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An internal index `i` was previously allocated as Elf64_Half which is uint16_t. Bumping to uint64_t increases the number of allowed symbols and prevents a segfault in processing a larger ramstage.debug file. Also introduce a separate counter for the number of sections. Change-Id: I9ad2f64c452cef2e7bf957f766600891cb5ae798 Signed-off-by: Damien Zammit Reviewed-on: https://review.coreboot.org/21360 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel Reviewed-by: Aaron Durbin Reviewed-by: Philippe Mathieu-Daudé --- util/cbfstool/elfheaders.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'util/cbfstool') diff --git a/util/cbfstool/elfheaders.c b/util/cbfstool/elfheaders.c index 67f01d4df1..acb25a7475 100644 --- a/util/cbfstool/elfheaders.c +++ b/util/cbfstool/elfheaders.c @@ -435,7 +435,8 @@ symtab_read(const struct buffer *in, struct parsed_elf *pelf, { Elf64_Ehdr *ehdr; Elf64_Shdr *shdr; - Elf64_Half i; + Elf64_Half shnum; + Elf64_Xword i; Elf64_Xword nsyms; Elf64_Sym *sym; struct buffer b; @@ -443,17 +444,17 @@ symtab_read(const struct buffer *in, struct parsed_elf *pelf, ehdr = &pelf->ehdr; shdr = NULL; - for (i = 0; i < ehdr->e_shnum; i++) { - if (pelf->shdr[i].sh_type != SHT_SYMTAB) + for (shnum = 0; shnum < ehdr->e_shnum; shnum++) { + if (pelf->shdr[shnum].sh_type != SHT_SYMTAB) continue; if (shdr != NULL) { ERROR("Multiple symbol sections found. %u and %u\n", - (unsigned int)(shdr - pelf->shdr), i); + (unsigned int)(shdr - pelf->shdr), shnum); return -1; } - shdr = &pelf->shdr[i]; + shdr = &pelf->shdr[shnum]; } if (shdr == NULL) { -- cgit v1.2.3