Fix gcc string truncation warnings
This commit is contained in:
parent
54ae394754
commit
25af959fe9
|
@ -48,7 +48,7 @@ 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;
|
||||||
strncpy(addr.sun_path, socket_path, sizeof(addr.sun_path));
|
strncpy(addr.sun_path, socket_path, sizeof(addr.sun_path) - 1);
|
||||||
addr.sun_path[sizeof(addr.sun_path) - 1] = 0;
|
addr.sun_path[sizeof(addr.sun_path) - 1] = 0;
|
||||||
int l = sizeof(struct sockaddr_un);
|
int l = sizeof(struct sockaddr_un);
|
||||||
if (connect(socketfd, (struct sockaddr *)&addr, l) == -1) {
|
if (connect(socketfd, (struct sockaddr *)&addr, l) == -1) {
|
||||||
|
|
|
@ -601,7 +601,7 @@ struct cmd_results *add_color(const char *name,
|
||||||
"Invalid color definition %s", color);
|
"Invalid color definition %s", color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strncpy(buffer, color, len);
|
strcpy(buffer, color);
|
||||||
// add default alpha channel if color was defined without it
|
// add default alpha channel if color was defined without it
|
||||||
if (len == 7) {
|
if (len == 7) {
|
||||||
buffer[7] = 'f';
|
buffer[7] = 'f';
|
||||||
|
|
|
@ -32,7 +32,7 @@ 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];
|
||||||
strncpy(cmd, tmp, sizeof(cmd));
|
strncpy(cmd, tmp, sizeof(cmd) - 1);
|
||||||
cmd[sizeof(cmd) - 1] = 0;
|
cmd[sizeof(cmd) - 1] = 0;
|
||||||
free(tmp);
|
free(tmp);
|
||||||
wlr_log(L_DEBUG, "Executing %s", cmd);
|
wlr_log(L_DEBUG, "Executing %s", cmd);
|
||||||
|
|
|
@ -64,7 +64,7 @@ void ipc_init(struct sway_server *server) {
|
||||||
|
|
||||||
// We want to use socket name set by user, not existing socket from another sway instance.
|
// We want to use socket name set by user, not existing socket from another sway instance.
|
||||||
if (getenv("SWAYSOCK") != NULL && access(getenv("SWAYSOCK"), F_OK) == -1) {
|
if (getenv("SWAYSOCK") != NULL && access(getenv("SWAYSOCK"), F_OK) == -1) {
|
||||||
strncpy(ipc_sockaddr->sun_path, getenv("SWAYSOCK"), sizeof(ipc_sockaddr->sun_path));
|
strncpy(ipc_sockaddr->sun_path, getenv("SWAYSOCK"), sizeof(ipc_sockaddr->sun_path) - 1);
|
||||||
ipc_sockaddr->sun_path[sizeof(ipc_sockaddr->sun_path) - 1] = 0;
|
ipc_sockaddr->sun_path[sizeof(ipc_sockaddr->sun_path) - 1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue