lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240106201010.29461-1-maks.mishinFZ@gmail.com>
Date: Sat,  6 Jan 2024 23:10:10 +0300
From: Maks Mishin <maks.mishinfz@...il.com>
To: Stephen Hemminger <stephen@...workplumber.org>
Cc: Maks Mishin <maks.mishinFZ@...il.com>,
	netdev@...r.kernel.org
Subject: [PATCH] ifstat: Add NULL pointer check for result of ll_index_to_name()

Result of ll_index_to_name() function do not being checked for NULL
pointer before using in strdup() function.
Add intermediate variable `name` for result of ll_index_to_name()
function. Function result -1 when `name` is NULL.

Signed-off-by: Maks Mishin <maks.mishinFZ@...il.com>
---
 misc/ifstat.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/misc/ifstat.c b/misc/ifstat.c
index f6f9ba50..e6c38812 100644
--- a/misc/ifstat.c
+++ b/misc/ifstat.c
@@ -129,7 +129,12 @@ static int get_nlmsg_extended(struct nlmsghdr *m, void *arg)
 		abort();
 
 	n->ifindex = ifsm->ifindex;
-	n->name = strdup(ll_index_to_name(ifsm->ifindex));
+	
+	const char* name = ll_index_to_name(ifsm->ifindex);
+	if (name == NULL) {
+		return -1;
+	}
+	n->name = strdup(name);
 
 	if (sub_type == NO_SUB_TYPE) {
 		memcpy(&n->val, RTA_DATA(tb[filter_type]), sizeof(n->val));
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ