From 2ca002f4af22aabbed89434440fc3443c8619295 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Tue, 3 Dec 2019 21:49:06 +0100 Subject: exit(2) on unsupported positional arguments on command line Change-Id: I3b8781e220326387f1c437c39aff8661326f1e0a --- src/ipaccess/ipaccess-proxy.c | 4 ++++ src/osmo-bsc/osmo_bsc_main.c | 5 +++++ src/utils/bs11_config.c | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/src/ipaccess/ipaccess-proxy.c b/src/ipaccess/ipaccess-proxy.c index 3d5f301d8..f4d620b34 100644 --- a/src/ipaccess/ipaccess-proxy.c +++ b/src/ipaccess/ipaccess-proxy.c @@ -1200,6 +1200,10 @@ static void handle_options(int argc, char** argv) break; } } + if (argc > optind) { + fprintf(stderr, "Unsupported positional arguments on command line\n"); + exit(2); + } if ((options_mask & (IPA_PROXY_OPT_LISTEN_IP | IPA_PROXY_OPT_BSC_IP)) != (IPA_PROXY_OPT_LISTEN_IP | IPA_PROXY_OPT_BSC_IP)) { printf("ERROR: You have to specify `--listen' and `--bsc' " diff --git a/src/osmo-bsc/osmo_bsc_main.c b/src/osmo-bsc/osmo_bsc_main.c index b18172cc4..6b1427903 100644 --- a/src/osmo-bsc/osmo_bsc_main.c +++ b/src/osmo-bsc/osmo_bsc_main.c @@ -171,6 +171,11 @@ static void handle_options(int argc, char **argv) break; } } + + if (argc > optind) { + fprintf(stderr, "Unsupported positional arguments on command line\n"); + exit(2); + } } /* Callback function for NACK on the OML NM */ diff --git a/src/utils/bs11_config.c b/src/utils/bs11_config.c index 2a2340c4a..7cd420354 100644 --- a/src/utils/bs11_config.c +++ b/src/utils/bs11_config.c @@ -854,6 +854,10 @@ static void handle_options(int argc, char **argv) if (optind+1 < argc) value = argv[optind+1]; } + if (optind+2 < argc) { + fprintf(stderr, "Unsupported positional arguments on command line\n"); + exit(2); + } } -- cgit v1.2.3