[PATCH] osmo-hlr[master]: db-tool: error-exit on too many arguments

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Fri Nov 10 16:00:33 UTC 2017


Review at  https://gerrit.osmocom.org/4778

db-tool: error-exit on too many arguments

Each arg parsing should increment optind, so if there are any surplus args in
the end, that's an error.

Change-Id: I9fc0a87d11db8c35061568e3f8b5a5547931a961
---
M src/hlr_db_tool.c
1 file changed, 6 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/78/4778/1

diff --git a/src/hlr_db_tool.c b/src/hlr_db_tool.c
index fb10f3e..d8a3584 100644
--- a/src/hlr_db_tool.c
+++ b/src/hlr_db_tool.c
@@ -159,6 +159,12 @@
 		print_help();
 		exit(EXIT_FAILURE);
 	}
+
+	if (argc - optind > 0) {
+		fprintf(stderr, "Too many arguments: '%s'\n", argv[optind]);
+		print_help();
+		exit(EXIT_FAILURE);
+	}
 }
 
 static void signal_hdlr(int signal)

-- 
To view, visit https://gerrit.osmocom.org/4778
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9fc0a87d11db8c35061568e3f8b5a5547931a961
Gerrit-PatchSet: 1
Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list