[packages/net-tools] Rel 3. Backport upstream buffer overflow fixes

arekm arekm at pld-linux.org
Thu Oct 29 08:50:58 CET 2026


commit 2a621f1347e21264617ae00c6b87f5d834c92dc4
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Thu Oct 29 00:16:43 2026 +0100

    Rel 3. Backport upstream buffer overflow fixes
    
    Fixes CVE-2025-46836.

 net-tools-CVE-2025-46836.patch         | 79 ++++++++++++++++++++++++++++++++++
 net-tools-ax25-netrom-overflow.patch   | 67 ++++++++++++++++++++++++++++
 net-tools-netrom-sprint-dangling.patch | 16 +++++++
 net-tools-proc_gen_fmt-overflow.patch  | 63 +++++++++++++++++++++++++++
 net-tools.spec                         | 10 ++++-
 5 files changed, 234 insertions(+), 1 deletion(-)
---
diff --git a/net-tools.spec b/net-tools.spec
index e456787..683c145 100644
--- a/net-tools.spec
+++ b/net-tools.spec
@@ -9,7 +9,7 @@ Summary(ru.UTF-8):	Базовые сетевые программы
 Summary(uk.UTF-8):	Базові програми мережі
 Name:		net-tools
 Version:	2.10
-Release:	2
+Release:	3
 License:	GPL v2+
 Group:		Networking/Admin
 Source0:	https://sourceforge.net/projects/net-tools/files/%{name}-%{version}.tar.xz
@@ -23,6 +23,10 @@ Patch3:		%{name}-make_config_h.patch
 Patch4:		%{name}-tr.patch
 Patch5:		%{name}-netstat-netlink-diag.patch
 Patch6:		net-tools-interface.patch
+Patch7:		%{name}-CVE-2025-46836.patch
+Patch8:		%{name}-proc_gen_fmt-overflow.patch
+Patch9:		%{name}-ax25-netrom-overflow.patch
+Patch10:	%{name}-netrom-sprint-dangling.patch
 URL:		https://sourceforge.net/projects/net-tools/
 BuildRequires:	gettext-tools
 Requires:	hostname
@@ -122,6 +126,10 @@ maszyny połączonej poprzez PLIP.
 %patch -P4 -p1
 %patch -P5 -p1
 %patch -P6 -p1
+%patch -P7 -p1
+%patch -P8 -p1
+%patch -P9 -p1
+%patch -P10 -p1
 
 %build
 %{__make} -j1 \
diff --git a/net-tools-CVE-2025-46836.patch b/net-tools-CVE-2025-46836.patch
new file mode 100644
index 0000000..6ed83ee
--- /dev/null
+++ b/net-tools-CVE-2025-46836.patch
@@ -0,0 +1,79 @@
+CVE-2025-46836: get_name() overflows the IFNAMSIZ buffer on long names in /proc/net/dev
+https://github.com/ecki/net-tools/commit/7a8f42fb20013a1493d8cae1c43436f85e656f2d
+https://github.com/ecki/net-tools/commit/ddb0e375fb9ca95bb69335540b85bbdaa2714348
+
+diff --git a/lib/interface.c b/lib/interface.c
+index 42cddda..e7890cb 100644
+--- a/lib/interface.c
++++ b/lib/interface.c
+@@ -211,32 +211,46 @@ out:
+ }
+ 
+ static const char *get_name(char *name, const char *p)
++/* Safe version — guarantees at most IFNAMSIZ‑1 bytes are copied
++   and the destination buffer is always NUL‑terminated.             */
+ {
+-    while (isspace(*p))
+-	p++;
+-    while (*p) {
+-	if (isspace(*p))
+-	    break;
+-	if (*p == ':') {	/* could be an alias */
+-		const char *dot = p++;
+- 		while (*p && isdigit(*p)) p++;
+-		if (*p == ':') {
+-			/* Yes it is, backup and copy it. */
+-			p = dot;
+-			*name++ = *p++;
+-			while (*p && isdigit(*p)) {
+-				*name++ = *p++;
+-			}
+-		} else {
+-			/* No, it isn't */
+-			p = dot;
+-	    }
+-	    p++;
+-	    break;
+-	}
+-	*name++ = *p++;
++    char       *dst = name;                 /* current write ptr          */
++    const char *end = name + IFNAMSIZ - 1;  /* last byte we may write     */
++
++    /* Skip leading white‑space. */
++    while (isspace((unsigned char)*p))
++        ++p;
++
++    /* Copy until white‑space, end of string, or buffer full. */
++    while (*p && !isspace((unsigned char)*p) && dst < end) {
++        if (*p == ':') {                    /* possible alias veth0:123:  */
++            const char *dot = p;            /* remember the colon         */
++            ++p;
++            while (*p && isdigit((unsigned char)*p))
++                ++p;
++
++            if (*p == ':') {                /* confirmed alias            */
++                p = dot;                    /* rewind and copy it all     */
++
++                /* copy the colon */
++                if (dst < end)
++                    *dst++ = *p++;
++
++                /* copy the digits */
++                while (*p && isdigit((unsigned char)*p) && dst < end)
++                    *dst++ = *p++;
++            } else {              /* if so treat as normal */
++                p = dot;
++            }
++            if (*p == ':')                  /* consume trailing colon */
++                ++p;
++            break;                          /* interface name ends here   */
++        }
++
++        *dst++ = *p++;                      /* ordinary character copy    */
+     }
+-    *name++ = '\0';
++
++    *dst = '\0';                            /* always NUL‑terminate       */
+     return p;
+ }
+ 
diff --git a/net-tools-ax25-netrom-overflow.patch b/net-tools-ax25-netrom-overflow.patch
new file mode 100644
index 0000000..f55f1fa
--- /dev/null
+++ b/net-tools-ax25-netrom-overflow.patch
@@ -0,0 +1,67 @@
+AX25_print()/NETROM_print() overflow buff[8] on callsigns with a two-digit SSID
+https://github.com/ecki/net-tools/commit/c084d1fea5de0f6dcaed4a59b38a4140bd2e9f13
+https://github.com/ecki/net-tools/commit/139f5d85e4e93bd75bc1072349bce19bf56c058a
+
+diff --git a/lib/ax25.c b/lib/ax25.c
+index 80a82c4..aee4214 100644
+--- a/lib/ax25.c
++++ b/lib/ax25.c
+@@ -47,9 +47,10 @@ static char AX25_errmsg[128];
+ 
+ extern struct aftype ax25_aftype;
+ 
++// align with NETROM_orint
+ static const char *AX25_print(const char *ptr)
+ {
+-    static char buff[8];
++    static char buff[10]; // N0CALL-15
+     int i;
+ 
+     for (i = 0; i < 6; i++) {
+@@ -58,9 +59,14 @@ static const char *AX25_print(const char *ptr)
+ 	    buff[i] = '\0';
+     }
+     buff[6] = '\0';
++
++    // add SSID
+     i = ((ptr[6] & 0x1E) >> 1);
+-    if (i != 0)
+-	sprintf(&buff[strlen(buff)], "-%d", i);
++    if (i != 0) {
++        int l = strlen(buff);
++        snprintf(&buff[l], sizeof(buff)-l, "-%d", i);
++    }
++
+     return (buff);
+ }
+ 
+diff --git a/lib/netrom.c b/lib/netrom.c
+index 6bcde2d..309e7cb 100644
+--- a/lib/netrom.c
++++ b/lib/netrom.c
+@@ -54,7 +54,7 @@ extern struct aftype netrom_aftype;
+ 
+ static const char *NETROM_print(const char *ptr)
+ {
+-    static char buff[8];
++    static char buff[10]; // N0CALL-15\0
+     int i;
+ 
+     for (i = 0; i < 6; i++) {
+@@ -63,9 +63,15 @@ static const char *NETROM_print(const char *ptr)
+ 	    buff[i] = '\0';
+     }
+     buff[6] = '\0';
++
++    // add SSID
+     i = ((ptr[6] & 0x1E) >> 1);
+     if (i != 0)
+-	sprintf(&buff[strlen(buff)], "-%d", i);
++    {
++        int l = strlen(buff); // 0-6
++        snprintf(&buff[l],sizeof(buff)-l, "-%d", i);
++    }
++
+     return (buff);
+ }
+ 
diff --git a/net-tools-netrom-sprint-dangling.patch b/net-tools-netrom-sprint-dangling.patch
new file mode 100644
index 0000000..d96adce
--- /dev/null
+++ b/net-tools-netrom-sprint-dangling.patch
@@ -0,0 +1,16 @@
+NETROM_sprint() returns a pointer to a dead stack buffer for an unset address
+https://github.com/ecki/net-tools/commit/45bf9973f01557ecfd7dfd65c265fe99ecda6cac
+
+diff --git a/lib/netrom.c b/lib/netrom.c
+index 309e7cb..d973762 100644
+--- a/lib/netrom.c
++++ b/lib/netrom.c
+@@ -81,7 +81,7 @@ static const char *NETROM_sprint(const struct sockaddr_storage *sasp, int numeri
+ {
+     const struct sockaddr_ax25 *ax25_sap = (const struct sockaddr_ax25 *)sasp;
+     const struct sockaddr *sap = (const struct sockaddr *)sasp;
+-    char buf[64];
++    static char buf[64];
+     if (sap->sa_family == 0xFFFF || sap->sa_family == 0)
+ 	return safe_strncpy(buf, _("[NONE SET]"), sizeof(buf));
+     return NETROM_print(ax25_sap->sax25_call.ax25_call);
diff --git a/net-tools-proc_gen_fmt-overflow.patch b/net-tools-proc_gen_fmt-overflow.patch
new file mode 100644
index 0000000..16f8e96
--- /dev/null
+++ b/net-tools-proc_gen_fmt-overflow.patch
@@ -0,0 +1,63 @@
+GHSA-w7jq-cmw2-cq59: proc_gen_fmt() overflows format[] on long /proc headers
+https://github.com/ecki/net-tools/commit/84041080a5d4794045b098ced90e0309bcbcff44
+
+diff --git a/lib/proc.c b/lib/proc.c
+index ce85fd1..7a5a977 100644
+--- a/lib/proc.c
++++ b/lib/proc.c
+@@ -17,6 +17,8 @@ char *proc_gen_fmt(const char *name, int more, FILE * fh,...)
+     char buf[512], format[512] = "";
+     char *title, *head, *hdr;
+     va_list ap;
++    size_t format_len = 0;
++    size_t format_size = sizeof(format);
+ 
+     if (!fgets(buf, (sizeof buf) - 1, fh))
+ 	return NULL;
+@@ -33,14 +35,43 @@ char *proc_gen_fmt(const char *name, int more, FILE * fh,...)
+ 	    *hdr++ = 0;
+ 
+ 	if (!strcmp(title, head)) {
+-	    strcat(format, va_arg(ap, char *));
++	    const char *arg = va_arg(ap, char *);
++	    size_t arg_len = strlen(arg);
++
++	    /* Check if we have enough space for format specifier + space */
++	    if (format_len + arg_len + 1 >= format_size) {
++		fprintf(stderr, "warning: format buffer overflow in %s\n", name);
++		va_end(ap);
++		return NULL;
++	    }
++
++	    strcpy(format + format_len, arg);
++	    format_len += arg_len;
++
+ 	    title = va_arg(ap, char *);
+ 	    if (!title || !head)
+ 		break;
+ 	} else {
+-	    strcat(format, "%*s");	/* XXX */
++	    /* Check if we have enough space for "%*s" */
++	    if (format_len + 3 >= format_size) {
++		fprintf(stderr, "warning: format buffer overflow in %s\n", name);
++		va_end(ap);
++		return NULL;
++	    }
++
++	    strcpy(format + format_len, "%*s");
++	    format_len += 3;
+ 	}
+-	strcat(format, " ");
++
++	/* Check if we have space for the trailing space */
++	if (format_len + 1 >= format_size) {
++	    fprintf(stderr, "warning: format buffer overflow in %s\n", name);
++	    va_end(ap);
++	    return NULL;
++	}
++
++	format[format_len++] = ' ';
++	format[format_len] = '\0';
+     }
+     va_end(ap);
+ 
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/net-tools.git/commitdiff/2a621f1347e21264617ae00c6b87f5d834c92dc4



More information about the pld-cvs-commit mailing list