Vadim Yanitskiy has uploaded this change for review. ( 
https://gerrit.osmocom.org/11851


Change subject: mobile: abort in case of argv handling errors
......................................................................

mobile: abort in case of argv handling errors

The process should be aborted if a non-existing command line
option or an incorrect parameter value is passed.

Change-Id: Ib656ad12f12429ed15dc2a1554901ffa51148ff6
---
M src/host/layer23/src/mobile/main.c
1 file changed, 10 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/51/11851/1

diff --git a/src/host/layer23/src/mobile/main.c 
b/src/host/layer23/src/mobile/main.c
index 115ac41..e015c30 100644
--- a/src/host/layer23/src/mobile/main.c
+++ b/src/host/layer23/src/mobile/main.c
@@ -99,7 +99,7 @@
                "offer socket\n");
 }

-static void handle_options(int argc, char **argv)
+static int handle_options(int argc, char **argv)
 {
        while (1) {
                int option_index = 0, c;
@@ -148,9 +148,12 @@
                        use_mncc_sock = 1;
                        break;
                default:
-                       break;
+                       /* Unknown parameter passed */
+                       return -EINVAL;
                }
        }
+
+       return 0;
 }

 void sighandler(int sigset)
@@ -218,7 +221,11 @@
        /* Init default stderr logging */
        osmo_init_logging2(l23_ctx, &log_info);

-       handle_options(argc, argv);
+       rc = handle_options(argc, argv);
+       if (rc) { /* Abort in case of parsing errors */
+               fprintf(stderr, "Error in command line options. Exiting.\n");
+               return 1;
+       }

        if (gsmtap_ip) {
                gsmtap_inst = gsmtap_source_init(gsmtap_ip, GSMTAP_UDP_PORT, 1);

--
To view, visit https://gerrit.osmocom.org/11851
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib656ad12f12429ed15dc2a1554901ffa51148ff6
Gerrit-Change-Number: 11851
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy <[email protected]>

Reply via email to