Module: kamailio
Branch: 5.5
Commit: 9427586f3af4dacfa2b3293ea6c5813a6b6c1e5c
URL:
https://github.com/kamailio/kamailio/commit/9427586f3af4dacfa2b3293ea6c5813…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-11-23T20:26:57+01:00
core: parser - detect pai/ppi headers spanning many lines
- GH #2837
(cherry picked from commit f0e8898d83c54e5e4383b70ba54ad340c5ae13b6)
---
Modified: src/core/parser/parse_ppi_pai.c
---
Diff:
https://github.com/kamailio/kamailio/commit/9427586f3af4dacfa2b3293ea6c5813…
Patch:
https://github.com/kamailio/kamailio/commit/9427586f3af4dacfa2b3293ea6c5813…
---
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)
{