summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--COPYING.LIB (renamed from COPYING)0
-rw-r--r--axconfig.c6
-rw-r--r--libax25.spec.in2
-rw-r--r--nrconfig.c4
-rw-r--r--rsconfig.c3
-rw-r--r--util.h12
6 files changed, 25 insertions, 2 deletions
diff --git a/COPYING b/COPYING.LIB
index 4362b49..4362b49 100644
--- a/COPYING
+++ b/COPYING.LIB
diff --git a/axconfig.c b/axconfig.c
index 84199c1..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
{
@@ -308,10 +310,12 @@ int ax25_config_load_ports(void)
break;
s = strchr(buffer, ':');
if (s) *s = 0;
- s = buffer;
+ s = buffer;
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/libax25.spec.in b/libax25.spec.in
index a77549a..5e8c789 100644
--- a/libax25.spec.in
+++ b/libax25.spec.in
@@ -53,7 +53,7 @@ rm -rf $RPM_BUILD_ROOT
%postun -p /sbin/ldconfig
%files
-%doc AUTHORS ChangeLog COPYING README
+%doc AUTHORS ChangeLog COPYING.LIB README
%dir %{_sysconfdir}/ax25
%config(noreplace) %{_sysconfdir}/ax25/axports
%config(noreplace) %{_sysconfdir}/ax25/nrports
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 */