summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--axconfig.c4
-rw-r--r--nrconfig.c4
-rw-r--r--rsconfig.c3
-rw-r--r--util.h12
4 files changed, 23 insertions, 0 deletions
diff --git a/axconfig.c b/axconfig.c
index 9486f5b..c6a2cb0 100644
--- a/axconfig.c
+++ b/axconfig.c
@@ -15,7 +15,9 @@
#include <netax25/axconfig.h>
#include <netax25/axlib.h>
#include <netrose/rose.h>
+
#include "pathnames.h"
+#include "util.h"
typedef struct _axport
{
@@ -312,6 +314,8 @@ int ax25_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;
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;
diff --git a/rsconfig.c b/rsconfig.c
index 21b91e0..8c7712b 100644
--- a/rsconfig.c
+++ b/rsconfig.c
@@ -18,6 +18,7 @@
#include <netax25/rsconfig.h>
#include "pathnames.h"
+#include "util.h"
typedef struct _rsport
{
@@ -237,6 +238,8 @@ int rs_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;
diff --git a/util.h b/util.h
new file mode 100644
index 0000000..2d2c252
--- /dev/null
+++ b/util.h
@@ -0,0 +1,12 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+#ifndef __LIBAX25_UTIL_H
+#define __LIBAX25_UTIL_H
+
+#define unreachable() \
+ do { __builtin_unreachable(); } while (0)
+
+#endif /* __LIBAX25_UTIL_H */