Module: kamailio
Branch: master
Commit: f0e8898d83c54e5e4383b70ba54ad340c5ae13b6
URL:
https://github.com/kamailio/kamailio/commit/f0e8898d83c54e5e4383b70ba54ad34…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-10-15T16:51:19+02:00
core: parser - detect pai/ppi headers spanning many lines
- GH #2837
---
Modified: src/core/parser/parse_ppi_pai.c
---
Diff:
https://github.com/kamailio/kamailio/commit/f0e8898d83c54e5e4383b70ba54ad34…
Patch:
https://github.com/kamailio/kamailio/commit/f0e8898d83c54e5e4383b70ba54ad34…
---
diff --git a/src/core/parser/parse_ppi_pai.c b/src/core/parser/parse_ppi_pai.c
index 4e4ebe392b..c60e33a9fd 100644
--- a/src/core/parser/parse_ppi_pai.c
+++ b/src/core/parser/parse_ppi_pai.c
@@ -65,6 +65,26 @@ int parse_pai_ppi_body(char *buf, int len, p_id_body_t **body)
while ((*tmp == ',') && (num_uri < NUM_PAI_BODIES))
{
tmp++;
+ while(tmp<buf+len && (*tmp==' ' || *tmp=='\t')) tmp++;
+ if(tmp>=buf+len) {
+ LM_ERR("no content after comma when parsing PAI/PPI body %u
'%.*s'\n",
+ num_uri, len, buf);
+ return -1;
+ }
+ if((tmp<buf+len-1 && *tmp=='\n')
+ || (tmp<buf+len-2 && *tmp=='\r' &&
*(tmp+1)=='\n')) {
+ if(*tmp=='\n') {
+ tmp++;
+ } else {
+ tmp += 2;
+ }
+ if(*tmp!=' ' && *tmp!='\t') {
+ LM_ERR("no space after EOL when parsing PAI/PPI body %u '%.*s'\n",
+ num_uri, len, buf);
+ return -1;
+ }
+ tmp++;
+ }
tmp = parse_addr_spec(tmp, buf+len, &uri_b[num_uri], 1);
if (uri_b[num_uri].error == PARSE_ERROR)
{