Browse code

carrierroute: fixed possible kamctl fifo segfault

- introduced checks to reject contiguous -{OPTION}{PARAMETER} in kamctl fifo commands
e.g.: kamctl fifo cr_activate_host "-dproxy -p 49 -h proxy1" is not allowed

Lucian Balaceanu authored on 19/01/2016 09:09:59
Showing 1 changed files
... ...
@@ -490,7 +490,15 @@ static int get_fifo_opts(str * buf, fifo_opt_t * opts, unsigned int opt_set[]) {
490 490
 		LM_DBG("token %.*s", opt_argv[i].len, opt_argv[i].s);
491 491
 		if (opt_argv[i].len >= 1) {
492 492
 			switch(*opt_argv[i].s) {
493
-					case '-': switch(opt_argv[i].s[1]) {
493
+					case '-': 
494
+						  /* -{OPTION}{PARAMETER} is not allowed */
495
+                                                  if (opt_argv[i].len != 2) {
496
+                                                        FIFO_ERR(E_WRONGOPT);
497
+                                                        LM_DBG("Unknown option: %.*s\n", opt_argv[i].len, opt_argv[i].s);
498
+                                                        return -1;
499
+                                                  }
500
+
501
+						  switch(opt_argv[i].s[1]) {
494 502
 							case OPT_DOMAIN_CHR:
495 503
 							op = OPT_DOMAIN;
496 504
 							used_opts |= O_DOMAIN;