summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2017-10-18 18:50:00 +0000
committermidipix <writeonce@midipix.org>2017-10-19 18:18:48 -0400
commitf3c99bb618fcec170a27058578fcef186d0a96c0 (patch)
tree45dcfee4f0877ca0c66466e6bea1e7397f3f9af5
parent224f38d84d94ecc12f4cf5b286967109ff3d9504 (diff)
downloadpemagine-f3c99bb618fcec170a27058578fcef186d0a96c0.tar.bz2
pemagine-f3c99bb618fcec170a27058578fcef186d0a96c0.tar.xz
pe_get_image_named_section_addr(): submit to a greater type-punned power.
-rw-r--r--src/headers/pe_get_image_section_tbl_addr.c12
1 files changed, 10 insertions, 2 deletions
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; pos<len; pos++)
ch[pos] = name[pos];
- for (; count; hdr++,count--)
- if (*(uint64_t *)hdr->sh_name == sname)
+ for (; count; hdr++,count--) {
+ shname = (uint64_t *)&hdr->sh_name[0];
+
+ if (*shname == sname)
return hdr;
+ }
}
return 0;