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]
Date:	Fri, 10 Jun 2016 13:42:07 +0200
From:	Phil Sutter <phil@....cc>
To:	Stephen Hemminger <shemming@...cade.com>
Cc:	netdev@...r.kernel.org
Subject: [iproute PATCH 8/9] tc: m_xt: Simplify argc adjusting in parse_ipt()

And while at it, also improve the error message in case too few
parameters have been given.

Signed-off-by: Phil Sutter <phil@....cc>
---
 tc/m_xt.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/tc/m_xt.c b/tc/m_xt.c
index 55ebadf2cf50a..f449c9d1a6638 100644
--- a/tc/m_xt.c
+++ b/tc/m_xt.c
@@ -124,7 +124,7 @@ static int parse_ipt(struct action_util *a, int *argc_p,
 
 	int c;
 	char **argv = *argv_p;
-	int argc = 0;
+	int argc;
 	char k[16];
 	int size = 0;
 	int iok = 0, ok = 0;
@@ -136,19 +136,14 @@ static int parse_ipt(struct action_util *a, int *argc_p,
 	xtables_init_all(&tmp_tcipt_globals, NFPROTO_IPV4);
 	set_lib_dir();
 
-	{
-		int i;
-
-		for (i = 0; i < *argc_p; i++) {
-			if (NULL == argv[i] || 0 == strcmp(argv[i], "action")) {
-				break;
-			}
-		}
-		argc = i;
+	/* parse only up until the next action */
+	for (argc = 0; argc < *argc_p; argc++) {
+		if (!argv[argc] || !strcmp(argv[argc], "action"))
+			break;
 	}
 
 	if (argc <= 2) {
-		fprintf(stderr, "bad arguments to ipt %d vs %d\n", argc, *argc_p);
+		fprintf(stderr, "too few arguments for xt, need at least '-j <target>'\n");
 		return -1;
 	}
 
-- 
2.8.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ