diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-09-03 10:57:21 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-03 10:57:21 -0400 |
commit | 7d353813d502d50439a7d50b55304fc835f3c7fd (patch) | |
tree | e1e504dfcfbf9b2a5c4ef4c68b5f5684eca7a0cb /sway | |
parent | 15c57f476f3407bb7eb28b4f906018d4dc192e36 (diff) | |
parent | d625d68d4a64ccf277663b26c52f4ca51d494e6a (diff) | |
download | sway-7d353813d502d50439a7d50b55304fc835f3c7fd.tar.xz |
Merge pull request #2563 from taiyu-len/fix/misaligned-pointer-access
fix misaligned integer stores/loads
Diffstat (limited to 'sway')
-rw-r--r-- | sway/ipc-server.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sway/ipc-server.c b/sway/ipc-server.c index ed710be5..fb5be27b 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c @@ -253,8 +253,8 @@ int ipc_client_handle_readable(int client_fd, uint32_t mask, void *data) { return 0; } - client->payload_length = buf32[0]; - client->current_command = (enum ipc_command_type)buf32[1]; + memcpy(&client->payload_length, &buf32[0], sizeof(buf32[0])); + memcpy(&client->current_command, &buf32[1], sizeof(buf32[1])); if (read_available - received >= (long)client->payload_length) { ipc_client_handle_command(client); @@ -832,8 +832,8 @@ bool ipc_send_reply(struct ipc_client *client, const char *payload, uint32_t pay uint32_t *data32 = (uint32_t*)(data + sizeof(ipc_magic)); memcpy(data, ipc_magic, sizeof(ipc_magic)); - data32[0] = payload_length; - data32[1] = client->current_command; + memcpy(&data32[0], &payload_length, sizeof(payload_length)); + memcpy(&data32[1], &client->current_command, sizeof(client->current_command)); while (client->write_buffer_len + ipc_header_size + payload_length >= client->write_buffer_size) { |