aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Engestrom <eric@engestrom.ch>2016-05-01 13:39:24 +0100
committerEric Engestrom <eric@engestrom.ch>2016-05-01 13:57:23 +0100
commitaece36cd22aa50015d1eb737b2b31a0b7087e813 (patch)
tree9ce1368de09405b187630fb730f103209a53a456
parentf7869d815a17b062f867478ceacc8c1d1cbac6c2 (diff)
common: fix potential buffer overflow
-rw-r--r--common/ipc-client.c3
1 files changed, 2 insertions, 1 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) {
sway_abort("Unable to open Unix socket");
}
addr.sun_family = AF_UNIX;
- strcpy(addr.sun_path, socket_path);
+ strncpy(addr.sun_path, socket_path, sizeof(addr.sun_path));
+ addr.sun_path[sizeof(addr.sun_path) - 1] = 0;
int l = sizeof(addr.sun_family) + strlen(addr.sun_path);
if (connect(socketfd, (struct sockaddr *)&addr, l) == -1) {
sway_abort("Unable to connect to %s", socket_path);