Преглед на файлове

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 преди 9 години
родител
ревизия
a86fa8f9c9
променени са 1 файла, в които са добавени 9 реда и са изтрити 1 реда
  1. 9 1
      modules/carrierroute/cr_fifo.c

+ 9 - 1
modules/carrierroute/cr_fifo.c

@@ -490,7 +490,15 @@ static int get_fifo_opts(str * buf, fifo_opt_t * opts, unsigned int opt_set[]) {
 		LM_DBG("token %.*s", opt_argv[i].len, opt_argv[i].s);
 		if (opt_argv[i].len >= 1) {
 			switch(*opt_argv[i].s) {
-					case '-': switch(opt_argv[i].s[1]) {
+					case '-': 
+						  /* -{OPTION}{PARAMETER} is not allowed */
+                                                  if (opt_argv[i].len != 2) {
+                                                        FIFO_ERR(E_WRONGOPT);
+                                                        LM_DBG("Unknown option: %.*s\n", opt_argv[i].len, opt_argv[i].s);
+                                                        return -1;
+                                                  }
+
+						  switch(opt_argv[i].s[1]) {
 							case OPT_DOMAIN_CHR:
 							op = OPT_DOMAIN;
 							used_opts |= O_DOMAIN;