[PATCH v4 1/2] nfacct: check cmd line argument for singleness

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It was possible to specify several equal options for list operation.

Signed-off-by: Alexey Perevalov <a.perevalov@xxxxxxxxxxx>
---
 src/nfacct.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/nfacct.c b/src/nfacct.c
index 091a5c9..e58b9af 100644
--- a/src/nfacct.c
+++ b/src/nfacct.c
@@ -63,6 +63,13 @@ static void nfacct_perror(const char *msg)
 	}
 }
 
+static void duparg(const char *key)
+{
+	fprintf(stderr, "Error: duplicate \"%s\" or collision with another "
+		"option \n", key);
+	exit(EXIT_FAILURE);
+}
+
 int main(int argc, char *argv[])
 {
 	int cmd = NFACCT_CMD_NONE, ret = 0;
@@ -177,8 +184,12 @@ static int nfacct_cmd_list(int argc, char *argv[])
 
 	for (i=2; i<argc; i++) {
 		if (strncmp(argv[i], "reset", strlen(argv[i])) == 0) {
+			if (zeroctr)
+				duparg(argv[i]);
 			zeroctr = true;
 		} else if (strncmp(argv[i], "xml", strlen(argv[i])) == 0) {
+			if (xml)
+				duparg(argv[i]);
 			xml = true;
 		} else {
 			nfacct_perror("unknown argument");
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux