tapif: fix strncpy

Adjust the strncpy() call in tapif.c to how this is coded
in other strncpy() invocations. Also gcc warns about this.

See patch #10142
This commit is contained in:
Florian La Roche 2021-11-22 08:34:22 +01:00 committed by Simon Goldschmidt
parent 7c3aab2ea2
commit 34e435c786

View File

@ -153,9 +153,9 @@ low_level_init(struct netif *netif)
memset(&ifr, 0, sizeof(ifr));
if (preconfigured_tapif) {
strncpy(ifr.ifr_name, preconfigured_tapif, sizeof(ifr.ifr_name));
strncpy(ifr.ifr_name, preconfigured_tapif, sizeof(ifr.ifr_name) - 1);
} else {
strncpy(ifr.ifr_name, DEVTAP_DEFAULT_IF, sizeof(ifr.ifr_name));
strncpy(ifr.ifr_name, DEVTAP_DEFAULT_IF, sizeof(ifr.ifr_name) - 1);
}
ifr.ifr_name[sizeof(ifr.ifr_name)-1] = 0; /* ensure \0 termination */