File net-tools-CVE-2025-46836-error-reporting.patch of Package net-tools
From 61f4890ae077bcf02aa2b5c3f8737349ee048ae9 Mon Sep 17 00:00:00 2001
From: skrab-sah <skrab.sah@gmail.com>
Date: Sun, 18 May 2025 01:58:36 +0530
Subject: [PATCH] Interface name size checking (#21)
Interface name size checking to provide more readable error.
---
ifconfig.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/ifconfig.c b/ifconfig.c
index 3b8bd5c..7688a79 100644
--- a/ifconfig.c
+++ b/ifconfig.c
@@ -330,7 +330,13 @@ int main(int argc, char **argv)
}
/* No. Fetch the interface name. */
spp = argv;
- safe_strncpy(ifr.ifr_name, *spp++, IFNAMSIZ);
+ size_t len = strlen(*spp);
+ if (len >= IFNAMSIZ)
+ {
+ fprintf(stderr, "%s(%lu): interface name length must be < %i\n", *spp, len, IFNAMSIZ);
+ return EXIT_FAILURE;
+ }
+ memcpy(ifr.ifr_name, *spp++, len+1);
if (*spp == (char *) NULL) {
int err = if_print(ifr.ifr_name);
(void) close(skfd);
--
2.48.1