Browse code

core: parser - detect pai/ppi headers spanning many lines

- GH #2837

Daniel-Constantin Mierla authored on 15/10/2021 14:49:42
Showing 1 changed files
... ...
@@ -65,6 +65,26 @@ int parse_pai_ppi_body(char *buf, int len, p_id_body_t **body)
65 65
 	while ((*tmp == ',') && (num_uri < NUM_PAI_BODIES))
66 66
 	{
67 67
 		tmp++;
68
+		while(tmp<buf+len && (*tmp==' ' || *tmp=='\t')) tmp++;
69
+		if(tmp>=buf+len) {
70
+			LM_ERR("no content after comma when parsing PAI/PPI body %u '%.*s'\n",
71
+					num_uri, len, buf);
72
+			return -1;
73
+		}
74
+		if((tmp<buf+len-1 && *tmp=='\n')
75
+				|| (tmp<buf+len-2 && *tmp=='\r' && *(tmp+1)=='\n')) {
76
+			if(*tmp=='\n') {
77
+				tmp++;
78
+			} else {
79
+				tmp += 2;
80
+			}
81
+			if(*tmp!=' ' && *tmp!='\t') {
82
+				LM_ERR("no space after EOL when parsing PAI/PPI body %u '%.*s'\n",
83
+						num_uri, len, buf);
84
+				return -1;
85
+			}
86
+			tmp++;
87
+		}
68 88
 		tmp = parse_addr_spec(tmp, buf+len, &uri_b[num_uri], 1);
69 89
 		if (uri_b[num_uri].error == PARSE_ERROR)
70 90
 		{