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 <[email protected]>

Reply via email to