aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/ipc-client.c8
-rw-r--r--sway/desktop/render.c3
-rw-r--r--sway/ipc-server.c8
3 files changed, 10 insertions, 9 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");
diff --git a/sway/desktop/render.c b/sway/desktop/render.c
index 5556e5b3..695213eb 100644
--- a/sway/desktop/render.c
+++ b/sway/desktop/render.c
@@ -346,7 +346,8 @@ static void render_titlebar(struct sway_output *output,
float output_scale = output->wlr_output->scale;
enum sway_container_layout layout = state->parent->current.layout;
list_t *children = state->parent->current.children;
- bool is_last_child = children->items[children->length - 1] == con;
+ bool is_last_child = children->length == 0 ||
+ children->items[children->length - 1] == con;
double output_x = output->swayc->current.swayc_x;
double output_y = output->swayc->current.swayc_y;
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) {