From f3c99bb618fcec170a27058578fcef186d0a96c0 Mon Sep 17 00:00:00 2001 From: midipix Date: Wed, 18 Oct 2017 18:50:00 +0000 Subject: pe_get_image_named_section_addr(): submit to a greater type-punned power. --- src/headers/pe_get_image_section_tbl_addr.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/headers') diff --git a/src/headers/pe_get_image_section_tbl_addr.c b/src/headers/pe_get_image_section_tbl_addr.c index 59ba777..56c55a6 100644 --- a/src/headers/pe_get_image_section_tbl_addr.c +++ b/src/headers/pe_get_image_section_tbl_addr.c @@ -40,6 +40,7 @@ struct pe_raw_sec_hdr * pe_get_image_named_section_addr(const void * base, const size_t len; uint32_t pos; uint64_t sname; + uint64_t * shname; if (!(hdr = pe_get_image_section_tbl_addr(base))) return 0; @@ -53,6 +54,10 @@ struct pe_raw_sec_hdr * pe_get_image_named_section_addr(const void * base, const if ((len = pe_impl_strlen_ansi(name)) > 8) { /* todo: long name support */ return 0; + + } else if (len == 0) { + return 0; + } else { sname = 0; ch = (char *)&sname; @@ -60,9 +65,12 @@ struct pe_raw_sec_hdr * pe_get_image_named_section_addr(const void * base, const for (pos=0; possh_name == sname) + for (; count; hdr++,count--) { + shname = (uint64_t *)&hdr->sh_name[0]; + + if (*shname == sname) return hdr; + } } return 0; -- cgit v1.2.3