Fix strncpy() compilation warnings

Fix strncpy() compilation warnings wherein the target string length did
not account for a nul terminator
This commit is contained in:
XANTRONIX Development 2020-10-22 23:03:22 +01:00 committed by XANTRONIX Industrial
parent 58d9a37786
commit 00879d33c5
3 changed files with 3 additions and 3 deletions

View file

@ -92,7 +92,7 @@ int main(int argc, char **argv) {
goto error_client_socket;
}
strncpy(ifreq.name, ifname, sizeof(ifreq.name));
strncpy(ifreq.name, ifname, sizeof(ifreq.name)-1);
ifreq.state = PATTY_AX25_SOCK_PROMISC;

View file

@ -109,7 +109,7 @@ static int pty_promisc(patty_client *client,
setsockopt_request.opt = PATTY_AX25_SOCK_IF;
setsockopt_request.len = sizeof(ifreq);
strncpy(ifreq.name, ifname, sizeof(ifreq.name));
strncpy(ifreq.name, ifname, sizeof(ifreq.name)-1);
ifreq.state = PATTY_AX25_SOCK_PROMISC;
call = PATTY_CLIENT_SETSOCKOPT;

View file

@ -458,7 +458,7 @@ int patty_ax25_server_if_add(patty_ax25_server *server,
goto error_if_fd;
}
strncpy(entry->name, name, sizeof(entry->name));
strncpy(entry->name, name, sizeof(entry->name)-1);
entry->iface = iface;