From: Mark Wielaard Date: Wed, 6 May 2015 14:01:55 +0000 (+0200) Subject: elflint: Use Use Elf64_Word for shdr->sh_info cnt. X-Git-Tag: elfutils-0.162~67 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9d0926538635fe9a2bda0684623516aaf4407ecb;p=thirdparty%2Felfutils.git elflint: Use Use Elf64_Word for shdr->sh_info cnt. On 32bit using int might overflow. https://bugzilla.redhat.com/show_bug.cgi?id=1170810#c31 Signed-off-by: Mark Wielaard --- diff --git a/src/ChangeLog b/src/ChangeLog index 486f20f1b..93f4aba24 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -2,6 +2,8 @@ * elflint.c (check_gnu_hash): Return early when 2nd hash function shift too big. + (check_verdef): Use Elf64_Word for shdr->sh_info cnt. + (check_verneed): Likewise. 2015-05-05 Mark Wielaard diff --git a/src/elflint.c b/src/elflint.c index 3abda7186..4e5364603 100644 --- a/src/elflint.c +++ b/src/elflint.c @@ -3037,8 +3037,10 @@ section [%2d] '%s': sh_link does not link to string table\n"), return; } unsigned int offset = 0; - for (int cnt = shdr->sh_info; --cnt >= 0; ) + for (Elf64_Word cnt = shdr->sh_info; cnt > 0; ) { + cnt--; + /* Get the data at the next offset. */ GElf_Verneed needmem; GElf_Verneed *need = gelf_getverneed (data, offset, &needmem); @@ -3196,8 +3198,10 @@ section [%2d] '%s': sh_link does not link to string table\n"), bool has_base = false; unsigned int offset = 0; - for (int cnt = shdr->sh_info; --cnt >= 0; ) + for (Elf64_Word cnt = shdr->sh_info; cnt > 0; ) { + cnt--; + /* Get the data at the next offset. */ GElf_Verdef defmem; GElf_Verdef *def = gelf_getverdef (data, offset, &defmem);