aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-09-03 10:57:21 -0400
committerGitHub <noreply@github.com>2018-09-03 10:57:21 -0400
commit7d353813d502d50439a7d50b55304fc835f3c7fd (patch)
treee1e504dfcfbf9b2a5c4ef4c68b5f5684eca7a0cb /common
parent15c57f476f3407bb7eb28b4f906018d4dc192e36 (diff)
parentd625d68d4a64ccf277663b26c52f4ca51d494e6a (diff)
Merge pull request #2563 from taiyu-len/fix/misaligned-pointer-access
fix misaligned integer stores/loads
Diffstat (limited to 'common')
-rw-r--r--common/ipc-client.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/common/ipc-client.c b/common/ipc-client.c
index 24a2f9c2..496fd131 100644
--- a/common/ipc-client.c
+++ b/common/ipc-client.c
@@ -78,8 +78,8 @@ struct ipc_response *ipc_recv_response(int socketfd) {
}
total = 0;
- response->size = data32[0];
- response->type = data32[1];
+ memcpy(&response->size, &data32[0], sizeof(data32[0]));
+ memcpy(&response->type, &data32[1], sizeof(data32[1]));
char *payload = malloc(response->size + 1);
if (!payload) {
goto error_2;
@@ -112,8 +112,8 @@ char *ipc_single_command(int socketfd, uint32_t type, const char *payload, uint3
char data[ipc_header_size];
uint32_t *data32 = (uint32_t *)(data + sizeof(ipc_magic));
memcpy(data, ipc_magic, sizeof(ipc_magic));
- data32[0] = *len;
- data32[1] = type;
+ memcpy(&data32[0], len, sizeof(*len));
+ memcpy(&data32[1], &type, sizeof(type));
if (write(socketfd, data, ipc_header_size) == -1) {
sway_abort("Unable to send IPC header");