summaryrefslogtreecommitdiffstats
path: root/nrconfig.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2021-07-29 09:13:19 +0200
committerRalf Baechle <ralf@linux-mips.org>2021-07-29 09:13:19 +0200
commit415b2d46a39302b21b51758e83f81e5439ab487c (patch)
treeed368dac7a67c276cf0c24a280181875e74bf2de /nrconfig.c
parentd0881ea1c01e0e782a24a73e23762626c1baf2f7 (diff)
axconfig.c, nrconfig.c, roseconfig.c: Fix GCC 11 warnings.
GCC 11's overyealously throws below warnings. Fixed by giving GCC a hint that the string actually is short enough to fit. libtool: compile: gcc -DHAVE_CONFIG_H -I. -DAX25_SYSCONFDIR=\"/usr/local/etc/ax25/\" -DAX25_LOCALSTATEDIR=\"/usr/local/var/ax25/\" -g -O2 -Wall -MT axconfig.lo -MD -MP -MF .deps/axconfig.Tpo -c axconfig.c -fPIC -DPIC -o .libs/axconfig.o axconfig.c: In function ‘ax25_config_load_ports’: axconfig.c:315:25: warning: ‘strncpy’ output may be truncated copying 15 bytes from a string of length 255 [-Wstringop-truncation] 315 | strncpy(ifr.ifr_name, s, IFNAMSIZ-1); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [...] libtool: compile: gcc -DHAVE_CONFIG_H -I. -DAX25_SYSCONFDIR=\"/usr/local/etc/ax25/\" -DAX25_LOCALSTATEDIR=\"/usr/local/var/ax25/\" -g -O2 -Wall -MT nrconfig.lo -MD -MP -MF .deps/nrconfig.Tpo -c nrconfig.c -fPIC -DPIC -o .libs/nrconfig.o nrconfig.c: In function ‘nr_config_load_ports’: nrconfig.c:294:25: warning: ‘strncpy’ output may be truncated copying 15 bytes from a string of length 255 [-Wstringop-truncation] 294 | strncpy(ifr.ifr_name, s, IFNAMSIZ-1); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [...] libtool: compile: gcc -DHAVE_CONFIG_H -I. -DAX25_SYSCONFDIR=\"/usr/local/etc/ax25/\" -DAX25_LOCALSTATEDIR=\"/usr/local/var/ax25/\" -g -O2 -Wall -MT rsconfig.lo -MD -MP -MF .deps/rsconfig.Tpo -c rsconfig.c -fPIC -DPIC -o .libs/rsconfig.o rsconfig.c: In function ‘rs_config_load_ports’: rsconfig.c:240:25: warning: ‘strncpy’ output may be truncated copying 15 bytes from a string of length 255 [-Wstringop-truncation] 240 | strncpy(ifr.ifr_name, s, IFNAMSIZ-1); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'nrconfig.c')
-rw-r--r--nrconfig.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/nrconfig.c b/nrconfig.c
index 003dfb2..18fb6e1 100644
--- a/nrconfig.c
+++ b/nrconfig.c
@@ -18,6 +18,8 @@
#include <netax25/axlib.h>
#include <netax25/nrconfig.h>
+#include "util.h"
+
typedef struct _nrport
{
struct _nrport *Next;
@@ -291,6 +293,8 @@ int nr_config_load_ports(void)
while (isspace(*s & 0xff)) ++s;
memset(&ifr, 0, sizeof(ifr));
+ if (strlen(s) >= IFNAMSIZ)
+ unreachable();
strncpy(ifr.ifr_name, s, IFNAMSIZ-1);
ifr.ifr_name[IFNAMSIZ-1] = 0;