Parcourir la source

regex: leave enough space in buffers for parenthesis and -ending

(cherry picked from commit 9cae069832c8f37ebf9e686b3fbcab5d63652755)
Daniel-Constantin Mierla il y a 5 ans
Parent
commit
79bc074ec4
1 fichiers modifiés avec 2 ajouts et 2 suppressions
  1. 2 2
      src/modules/regex/regex_mod.c

+ 2 - 2
src/modules/regex/regex_mod.c

@@ -275,7 +275,7 @@ static int load_pcres(int action)
 	/* Read the file and extract the patterns */
 	memset(line, 0, FILE_MAX_LINE);
 	i = -1;
-	while (fgets(line, FILE_MAX_LINE, f) != NULL) {
+	while (fgets(line, FILE_MAX_LINE-4, f) != NULL) {
 
 		/* Ignore comments and lines starting by space, tab, CR, LF */
 		if(isspace(line[0]) || line[0]=='#') {
@@ -306,7 +306,7 @@ static int load_pcres(int action)
 		}
 
 		/* Check if the patter size is too big (aprox) */
-		if (strlen(patterns[i]) + strlen(line) >= group_max_size - 2) {
+		if (strlen(patterns[i]) + strlen(line) >= group_max_size - 4) {
 			LM_ERR("pattern max file exceeded\n");
 			fclose(f);
 			goto err;