From 34e435c78611fbf21c49c5ddb6c395a097e24cc7 Mon Sep 17 00:00:00 2001 From: Florian La Roche Date: Mon, 22 Nov 2021 08:34:22 +0100 Subject: [PATCH] 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 --- contrib/ports/unix/port/netif/tapif.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/ports/unix/port/netif/tapif.c b/contrib/ports/unix/port/netif/tapif.c index b5f8ad20..cff07838 100644 --- a/contrib/ports/unix/port/netif/tapif.c +++ b/contrib/ports/unix/port/netif/tapif.c @@ -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 */