From de921420854434dbcfdb469ebdcfdb9311755fc7 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Thu, 28 Apr 2011 21:47:14 +0200 Subject: [PATCH] Fix unaligned memory access on sparc (Thanks David Coppa) --- src/ipc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ipc.c b/src/ipc.c index 98bfbcf8..e9318e7b 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -463,7 +463,8 @@ static void ipc_receive_message(EV_P_ struct ev_io *w, int revents) { n -= strlen(I3_IPC_MAGIC); /* The next 32 bit after the magic are the message size */ - uint32_t message_size = *((uint32_t*)message); + uint32_t message_size; + memcpy(&message_size, (uint32_t*)message, sizeof(uint32_t)); message += sizeof(uint32_t); n -= sizeof(uint32_t); @@ -473,7 +474,8 @@ static void ipc_receive_message(EV_P_ struct ev_io *w, int revents) { } /* The last 32 bits of the header are the message type */ - uint32_t message_type = *((uint32_t*)message); + uint32_t message_type; + memcpy(&message_type, (uint32_t*)message, sizeof(uint32_t)); message += sizeof(uint32_t); n -= sizeof(uint32_t);