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-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <105e614b4c8ab46aa6b70c75111848d8e57aff0c.1682894692.git.nvinson234@gmail.com>
Date:   Sun, 30 Apr 2023 18:50:52 -0400
From:   Nicholas Vinson <nvinson234@...il.com>
To:     mkubecek@...e.cz
Cc:     Nicholas Vinson <nvinson234@...il.com>, netdev@...r.kernel.org
Subject: [PATCH ethtool 3/3] Fix potentinal null-pointer derference issues.

Found via gcc -fanalyzer. Analyzer claims that it's possible certain
functions may receive a NULL pointer when handling CLI arguments. Adding
NULL pointer checks to correct the issues.

Signed-off-by: Nicholas Vinson <nvinson234@...il.com>
---
 ethtool.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/ethtool.c b/ethtool.c
index 98690df..4ec1e23 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -6182,16 +6182,18 @@ static int find_option(char *arg)
 	size_t len;
 	int k;
 
-	for (k = 1; args[k].opts; k++) {
-		opt = args[k].opts;
-		for (;;) {
-			len = strcspn(opt, "|");
-			if (strncmp(arg, opt, len) == 0 && arg[len] == 0)
-				return k;
-
-			if (opt[len] == 0)
-				break;
-			opt += len + 1;
+	if (arg) {
+		for (k = 1; args[k].opts; k++) {
+			opt = args[k].opts;
+			for (;;) {
+				len = strcspn(opt, "|");
+				if (strncmp(arg, opt, len) == 0 && arg[len] == 0)
+					return k;
+
+				if (opt[len] == 0)
+					break;
+				opt += len + 1;
+			}
 		}
 	}
 
@@ -6457,7 +6459,7 @@ int main(int argc, char **argp)
 		argp++;
 		argc--;
 	} else {
-		if ((*argp)[0] == '-')
+		if (!*argp || (*argp)[0] == '-')
 			exit_bad_args();
 		k = 0;
 	}
-- 
2.40.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ