summaryrefslogtreecommitdiffstats
path: root/src/bplist.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2017-05-29 03:54:24 +0200
committerGravatar Nikias Bassen2017-05-29 03:54:24 +0200
commit292994b09fcfac64e14de3b20eab7821614e33dd (patch)
treebf4013c0d1f6c8911f7a54397290f0dc0e137b46 /src/bplist.c
parent5c6e695ca942f9a417d24e58f14d51f3e8e1885d (diff)
downloadlibplist-292994b09fcfac64e14de3b20eab7821614e33dd.tar.gz
libplist-292994b09fcfac64e14de3b20eab7821614e33dd.tar.bz2
bplist: Work around misaligned reads reported by AddressSanitizer
These misaligned reads reported by ASAN might lead to undefined behavior.
Diffstat (limited to 'src/bplist.c')
-rw-r--r--src/bplist.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/bplist.c b/src/bplist.c
index 9acd6ae..67513e6 100644
--- a/src/bplist.c
+++ b/src/bplist.c
@@ -269,11 +269,11 @@ static plist_t parse_real_node(const char **bnode, uint8_t size)
switch (size)
{
case sizeof(uint32_t):
- *(uint32_t*)buf = float_bswap32(*(uint32_t*)*bnode);
+ *(uint32_t*)buf = float_bswap32(get_unaligned((uint32_t*)*bnode));
data->realval = *(float *) buf;
break;
case sizeof(uint64_t):
- *(uint64_t*)buf = float_bswap64(*(uint64_t*)*bnode);
+ *(uint64_t*)buf = float_bswap64(get_unaligned((uint64_t*)*bnode));
data->realval = *(double *) buf;
break;
default:
@@ -394,7 +394,7 @@ static plist_t parse_unicode_node(const char **bnode, uint64_t size)
return NULL;
}
for (i = 0; i < size; i++)
- unicodestr[i] = be16toh(((uint16_t*)*bnode)[i]);
+ unicodestr[i] = be16toh(get_unaligned((uint16_t*)(*bnode+(i<<1))));
tmpstr = plist_utf16_to_utf8(unicodestr, size, &items_read, &items_written);
free(unicodestr);