summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2015-12-14 06:19:33 -0500
committermidipix <writeonce@midipix.org>2016-11-10 23:35:33 -0500
commit7d801c1d9c3b30bcfcb7207f84dfae7395224781 (patch)
treecff38abb4c0ecf27054bf22d2a2c4a4d1f679cc3
parent4eb4f9a7602f4397d75396f76a13c636c451dcfc (diff)
downloadperk-7d801c1d9c3b30bcfcb7207f84dfae7395224781.tar.bz2
perk-7d801c1d9c3b30bcfcb7207f84dfae7395224781.tar.xz
strict-aliasing rule compliance.
-rw-r--r--src/logic/pe_get_image_meta.c7
-rw-r--r--src/reader/pe_read_coff_header.c5
2 files changed, 9 insertions, 3 deletions
diff --git a/src/logic/pe_get_image_meta.c b/src/logic/pe_get_image_meta.c
index 78b8b91..699b3a2 100644
--- a/src/logic/pe_get_image_meta.c
+++ b/src/logic/pe_get_image_meta.c
@@ -141,9 +141,14 @@ int pe_get_image_meta(const struct pe_raw_image * image, struct pe_image_meta **
+ m->idata[i].import_lookup_tbl_rva - m->hidata->virtual_addr);
/* items */
+ uint32_t * hint;
m->idata[i].count = 0;
+
if (m->idata[i].import_lookup_tbl_rva) {
- for (pitem=m->idata[i].aitems; *(uint32_t *)pitem->hint_name_tbl_rva; pitem++)
+ pitem = m->idata[i].aitems;
+ hint = (uint32_t *)pitem->hint_name_tbl_rva;
+
+ for (; *hint; hint=(uint32_t *)((++pitem)->hint_name_tbl_rva))
m->idata[i].count++;
if (!(m->idata[i].items = calloc(m->idata[i].count,sizeof(*(m->idata[i].items)))))
diff --git a/src/reader/pe_read_coff_header.c b/src/reader/pe_read_coff_header.c
index 79ed730..a0a0b7f 100644
--- a/src/reader/pe_read_coff_header.c
+++ b/src/reader/pe_read_coff_header.c
@@ -6,8 +6,9 @@
int pe_read_coff_header(const struct pe_coff_file_hdr * p, struct pe_meta_coff_file_hdr * m)
{
- if ((p->signature[0] != 'P') || (p->signature[1] != 'E')
- || *(uint16_t *)&p->signature[2])
+ uint16_t * pzero = (uint16_t *)&p->signature[2];
+
+ if ((p->signature[0] != 'P') || (p->signature[1] != 'E') || *pzero)
return PERK_BAD_COFF_HEADER;
#if (BYTE_ORDER == LITTLE_ENDIAN)