Browse code

core: fix regex error for modules parameters

Ambiguous was possible in params for multiple modules in one config line.

(cherry picked from commit 198b116b0d58e61d9c35fdd0988ce97192b8f61e)

Dmitri Savolainen authored on 09/07/2016 14:05:09
Showing 1 changed files
... ...
@@ -59,15 +59,17 @@ int set_mod_param_regex(char* regex, char* name, modparam_t type, void* val)
59 59
 	}
60 60
 
61 61
 	len = strlen(regex);
62
-	reg = pkg_malloc(len + 2 + 1);
62
+	reg = pkg_malloc(len + 4 + 1);
63 63
 	if (reg == 0) {
64 64
 		LM_ERR("No memory left\n");
65 65
 		return -1;
66 66
 	}
67 67
 	reg[0] = '^';
68
-	memcpy(reg + 1, regex, len);
69
-	reg[len + 1] = '$';
70
-	reg[len + 2] = '\0';
68
+	reg[1] = '(';
69
+	memcpy(reg + 2, regex, len);
70
+	reg[len + 2] = ')';
71
+	reg[len + 3] = '$';
72
+	reg[len + 4] = '\0';
71 73
 
72 74
 	if (regcomp(&preg, reg, REG_EXTENDED | REG_NOSUB | REG_ICASE)) {
73 75
 		LM_ERR("Error while compiling regular expression\n");