naccyde / rpms / iproute

Forked from rpms/iproute 9 months ago
Clone

Blame SOURCES/0155-tc-m_xt-Simplify-argc-adjusting-in-parse_ipt.patch

4aca6e
From e1d15d63d531aa08fd6abe021aba5e287e13d527 Mon Sep 17 00:00:00 2001
4aca6e
From: Phil Sutter <psutter@redhat.com>
4aca6e
Date: Tue, 4 Apr 2017 16:23:42 +0200
4aca6e
Subject: [PATCH] tc: m_xt: Simplify argc adjusting in parse_ipt()
4aca6e
4aca6e
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1326726
4aca6e
Upstream Status: iproute2.git commit f6ddd9c5da4e5
4aca6e
4aca6e
commit f6ddd9c5da4e552322baf237075aae6db17237d4
4aca6e
Author: Phil Sutter <phil@nwl.cc>
4aca6e
Date:   Fri Jun 10 13:42:07 2016 +0200
4aca6e
4aca6e
    tc: m_xt: Simplify argc adjusting in parse_ipt()
4aca6e
4aca6e
    And while at it, also improve the error message in case too few
4aca6e
    parameters have been given.
4aca6e
4aca6e
    Signed-off-by: Phil Sutter <phil@nwl.cc>
4aca6e
---
4aca6e
 tc/m_xt.c | 17 ++++++-----------
4aca6e
 1 file changed, 6 insertions(+), 11 deletions(-)
4aca6e
4aca6e
diff --git a/tc/m_xt.c b/tc/m_xt.c
4aca6e
index e0ed8a4..da3f7ab 100644
4aca6e
--- a/tc/m_xt.c
4aca6e
+++ b/tc/m_xt.c
4aca6e
@@ -124,7 +124,7 @@ static int parse_ipt(struct action_util *a,int *argc_p,
4aca6e
 
4aca6e
 	int c;
4aca6e
 	char **argv = *argv_p;
4aca6e
-	int argc = 0;
4aca6e
+	int argc;
4aca6e
 	char k[16];
4aca6e
 	int size = 0;
4aca6e
 	int iok = 0, ok = 0;
4aca6e
@@ -136,19 +136,14 @@ static int parse_ipt(struct action_util *a,int *argc_p,
4aca6e
 	xtables_init_all(&tmp_tcipt_globals, NFPROTO_IPV4);
4aca6e
 	set_lib_dir();
4aca6e
 
4aca6e
-	{
4aca6e
-		int i;
4aca6e
-
4aca6e
-		for (i = 0; i < *argc_p; i++) {
4aca6e
-			if (NULL == argv[i] || 0 == strcmp(argv[i], "action")) {
4aca6e
-				break;
4aca6e
-			}
4aca6e
-		}
4aca6e
-		argc = i;
4aca6e
+	/* parse only up until the next action */
4aca6e
+	for (argc = 0; argc < *argc_p; argc++) {
4aca6e
+		if (!argv[argc] || !strcmp(argv[argc], "action"))
4aca6e
+			break;
4aca6e
 	}
4aca6e
 
4aca6e
 	if (argc <= 2) {
4aca6e
-		fprintf(stderr, "bad arguments to ipt %d vs %d\n", argc, *argc_p);
4aca6e
+		fprintf(stderr, "too few arguments for xt, need at least '-j <target>'\n");
4aca6e
 		return -1;
4aca6e
 	}
4aca6e
 
4aca6e
-- 
4aca6e
1.8.3.1
4aca6e