diff options
-rw-r--r-- | common/ipc-client.c | 3 | ||||
-rw-r--r-- | sway/commands.c | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/common/ipc-client.c b/common/ipc-client.c index 93f2963c..997a87d1 100644 --- a/common/ipc-client.c +++ b/common/ipc-client.c | |||
@@ -32,7 +32,8 @@ int ipc_open_socket(const char *socket_path) { | |||
32 | sway_abort("Unable to open Unix socket"); | 32 | sway_abort("Unable to open Unix socket"); |
33 | } | 33 | } |
34 | addr.sun_family = AF_UNIX; | 34 | addr.sun_family = AF_UNIX; |
35 | strcpy(addr.sun_path, socket_path); | 35 | strncpy(addr.sun_path, socket_path, sizeof(addr.sun_path)); |
36 | addr.sun_path[sizeof(addr.sun_path) - 1] = 0; | ||
36 | int l = sizeof(addr.sun_family) + strlen(addr.sun_path); | 37 | int l = sizeof(addr.sun_family) + strlen(addr.sun_path); |
37 | if (connect(socketfd, (struct sockaddr *)&addr, l) == -1) { | 38 | if (connect(socketfd, (struct sockaddr *)&addr, l) == -1) { |
38 | sway_abort("Unable to connect to %s", socket_path); | 39 | sway_abort("Unable to connect to %s", socket_path); |
diff --git a/sway/commands.c b/sway/commands.c index 79591925..73e9ffaf 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -506,7 +506,8 @@ static struct cmd_results *cmd_exec_always(int argc, char **argv) { | |||
506 | 506 | ||
507 | // Put argument into cmd array | 507 | // Put argument into cmd array |
508 | char cmd[4096]; | 508 | char cmd[4096]; |
509 | strcpy(cmd, tmp); | 509 | strncpy(cmd, tmp, sizeof(cmd)); |
510 | cmd[sizeof(cmd) - 1] = 0; | ||
510 | free(tmp); | 511 | free(tmp); |
511 | sway_log(L_DEBUG, "Executing %s", cmd); | 512 | sway_log(L_DEBUG, "Executing %s", cmd); |
512 | 513 | ||