diff options
author | 2018-09-03 10:57:21 -0400 | |
---|---|---|
committer | 2018-09-03 10:57:21 -0400 | |
commit | 7d353813d502d50439a7d50b55304fc835f3c7fd (patch) | |
tree | e1e504dfcfbf9b2a5c4ef4c68b5f5684eca7a0cb /common/ipc-client.c | |
parent | Merge pull request #2565 from ianyfan/fix-splashscreen-crash (diff) | |
parent | prevent ub caused by misaligned stores/loads (diff) | |
download | sway-7d353813d502d50439a7d50b55304fc835f3c7fd.tar.gz sway-7d353813d502d50439a7d50b55304fc835f3c7fd.tar.zst sway-7d353813d502d50439a7d50b55304fc835f3c7fd.zip |
Merge pull request #2563 from taiyu-len/fix/misaligned-pointer-access
fix misaligned integer stores/loads
Diffstat (limited to 'common/ipc-client.c')
-rw-r--r-- | common/ipc-client.c | 8 |
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) { | |||
78 | } | 78 | } |
79 | 79 | ||
80 | total = 0; | 80 | total = 0; |
81 | response->size = data32[0]; | 81 | memcpy(&response->size, &data32[0], sizeof(data32[0])); |
82 | response->type = data32[1]; | 82 | memcpy(&response->type, &data32[1], sizeof(data32[1])); |
83 | char *payload = malloc(response->size + 1); | 83 | char *payload = malloc(response->size + 1); |
84 | if (!payload) { | 84 | if (!payload) { |
85 | goto error_2; | 85 | goto error_2; |
@@ -112,8 +112,8 @@ char *ipc_single_command(int socketfd, uint32_t type, const char *payload, uint3 | |||
112 | char data[ipc_header_size]; | 112 | char data[ipc_header_size]; |
113 | uint32_t *data32 = (uint32_t *)(data + sizeof(ipc_magic)); | 113 | uint32_t *data32 = (uint32_t *)(data + sizeof(ipc_magic)); |
114 | memcpy(data, ipc_magic, sizeof(ipc_magic)); | 114 | memcpy(data, ipc_magic, sizeof(ipc_magic)); |
115 | data32[0] = *len; | 115 | memcpy(&data32[0], len, sizeof(*len)); |
116 | data32[1] = type; | 116 | memcpy(&data32[1], &type, sizeof(type)); |
117 | 117 | ||
118 | if (write(socketfd, data, ipc_header_size) == -1) { | 118 | if (write(socketfd, data, ipc_header_size) == -1) { |
119 | sway_abort("Unable to send IPC header"); | 119 | sway_abort("Unable to send IPC header"); |