Fix strncpy() buffer size compiler warnings

This commit is contained in:
XANTRONIX Development 2020-08-07 17:59:16 -04:00 committed by XANTRONIX Industrial
parent ca06f34eed
commit b2d3d3e03f
4 changed files with 6 additions and 6 deletions

View file

@ -27,7 +27,7 @@ patty_client *patty_client_new(const char *path) {
memset(&addr, '\0', sizeof(addr));
addr.sun_family = AF_UNIX;
strncpy(addr.sun_path, path, sizeof(addr.sun_path));
strncpy(addr.sun_path, path, sizeof(addr.sun_path)-1);
if (connect(client->fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
goto error_connect;

View file

@ -191,7 +191,7 @@ patty_kiss_tnc *patty_kiss_tnc_new(const char *device) {
memset(&addr, '\0', sizeof(addr));
addr.sun_family = AF_UNIX;
strncpy(addr.sun_path, device, sizeof(addr.sun_path));
strncpy(addr.sun_path, device, sizeof(addr.sun_path)-1);
if (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
goto error_connect;

View file

@ -46,7 +46,7 @@ patty_ax25_server *patty_ax25_server_new(const char *path) {
memset(server, '\0', sizeof(*server));
strncpy(server->path, path, PATTY_AX25_SOCK_PATH_SIZE);
strncpy(server->path, path, sizeof(server->path)-1);
if ((server->ifaces = patty_list_new()) == NULL) {
goto error_list_new_ifaces;
@ -523,7 +523,7 @@ static int respond_accept(int client,
}
if (path) {
strncpy(response.path, path, sizeof(response.path));
strncpy(response.path, path, sizeof(response.path)-1);
}
return write(client, &response, sizeof(response));
@ -957,7 +957,7 @@ static int listen_unix(patty_ax25_server *server, const char *path) {
memset(&addr, '\0', sizeof(addr));
addr.sun_family = AF_UNIX;
strncpy(addr.sun_path, path, sizeof(addr.sun_path));
strncpy(addr.sun_path, path, sizeof(addr.sun_path)-1);
if (bind(server->fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
goto error_bind;

View file

@ -30,7 +30,7 @@ static int bind_pty(patty_ax25_sock *sock) {
goto error_ptsname;
}
(void)strncpy(sock->pty, pty, sizeof(sock->pty));
(void)strncpy(sock->pty, pty, sizeof(sock->pty)-1);
return 0;