mirror of
https://github.com/swaywm/sway.git
synced 2024-11-14 06:24:20 +01:00
Merge pull request #625 from 1ace/fix/buffer-overflow
Fix a couple potential buffer overflows
This commit is contained in:
commit
4915f97618
@ -32,7 +32,8 @@ int ipc_open_socket(const char *socket_path) {
|
|||||||
sway_abort("Unable to open Unix socket");
|
sway_abort("Unable to open Unix socket");
|
||||||
}
|
}
|
||||||
addr.sun_family = AF_UNIX;
|
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);
|
int l = sizeof(addr.sun_family) + strlen(addr.sun_path);
|
||||||
if (connect(socketfd, (struct sockaddr *)&addr, l) == -1) {
|
if (connect(socketfd, (struct sockaddr *)&addr, l) == -1) {
|
||||||
sway_abort("Unable to connect to %s", socket_path);
|
sway_abort("Unable to connect to %s", socket_path);
|
||||||
|
@ -506,7 +506,8 @@ static struct cmd_results *cmd_exec_always(int argc, char **argv) {
|
|||||||
|
|
||||||
// Put argument into cmd array
|
// Put argument into cmd array
|
||||||
char cmd[4096];
|
char cmd[4096];
|
||||||
strcpy(cmd, tmp);
|
strncpy(cmd, tmp, sizeof(cmd));
|
||||||
|
cmd[sizeof(cmd) - 1] = 0;
|
||||||
free(tmp);
|
free(tmp);
|
||||||
sway_log(L_DEBUG, "Executing %s", cmd);
|
sway_log(L_DEBUG, "Executing %s", cmd);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user