Daniel-Constantin Mierla
2021-05-31 08:46:33 UTC
Content preview: Module: kamailio Branch: master Commit: 9da83aae38199afa82d8b4eab4efd7b48d81b0b9
URL: https://github.com/kamailio/kamailio/commit/9da83aae38199afa82d8b4eab4efd7b48d81b0b9
Author: Daniel-Constantin Mierla <***@gmail.com> Committer: Daniel-Constantin
Mierla <***@gmail.com> Date: 2021-05-31T10:44:37+02:00
Content analysis details: (-2.4 points, 5.5 required)
pts rule name description
---- ---------------------- --------------------------------------------------
-1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP
-1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1%
[score: 0.0000]
1.0 FORGED_GMAIL_RCVD 'From' gmail.com does not match 'Received'
headers
0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail
provider (miconda[at]gmail.com)
0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level
mail domains are different
0.0 DKIM_ADSP_CUSTOM_MED No valid author signature, adsp_override is
CUSTOM_MED
0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and
EnvelopeFrom freemail headers are
different
-1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list
manager
Module: kamailio
Branch: master
Commit: 9da83aae38199afa82d8b4eab4efd7b48d81b0b9
URL: https://github.com/kamailio/kamailio/commit/9da83aae38199afa82d8b4eab4efd7b48d81b0b9
Author: Daniel-Constantin Mierla <***@gmail.com>
Committer: Daniel-Constantin Mierla <***@gmail.com>
Date: 2021-05-31T10:44:37+02:00
textops: new function for finding start of a header
- use it to find Content-Type start
- GH #2748
---
Modified: src/modules/textops/textops.c
---
Diff: https://github.com/kamailio/kamailio/commit/9da83aae38199afa82d8b4eab4efd7b48d81b0b9.diff
Patch: https://github.com/kamailio/kamailio/commit/9da83aae38199afa82d8b4eab4efd7b48d81b0b9.patch
---
diff --git a/src/modules/textops/textops.c b/src/modules/textops/textops.c
index b192c1306c..cbc2309cfe 100644
--- a/src/modules/textops/textops.c
+++ b/src/modules/textops/textops.c
@@ -1597,6 +1597,52 @@ static inline int find_line_start(char *text, unsigned int text_len,
return 0;
}
+static inline int find_hdr_line_start(char *hname, unsigned int hname_len,
+ char **buf, unsigned int *buf_len)
+{
+ hdr_field_t h1;
+ hdr_field_t h2;
+ str sname;
+ char *ch, *start;
+ unsigned int len;
+
+ sname.s = hname;
+ sname.len = hname_len;
+
+ start = *buf;
+ len = *buf_len;
+ if(parse_hname2_str(&sname, &h1)==NULL) {
+ LM_ERR("not a header name: %.*s\n", hname_len, hname);
+ return 0;
+ }
+
+ while (hname_len <= len) {
+ if(parse_hname2(start, start + hname_len, &h2)!=NULL) {
+ if(h1.type>0 && h1.type==h2.type) {
+ *buf = start;
+ *buf_len = len;
+ return 1;
+ } else if(cmp_hdrname_str(&h1.name, &h2.name)==0) {
+ *buf = start;
+ *buf_len = len;
+ return 1;
+ }
+ }
+ if ((ch = memchr(start, 13, len - 1))) {
+ if (*(ch + 1) != 10) {
+ LM_ERR("No LF after CR\n");
+ return 0;
+ }
+ len = len - (ch - start + 2);
+ start = ch + 2;
+ } else {
+ LM_ERR("No CRLF found\n");
+ return 0;
+ }
+ }
+ return 0;
+}
+
/**
* return:
* 1: multipart
@@ -1645,7 +1691,7 @@ static int ki_filter_body(struct sip_msg* msg, str *content_type)
start = body.s;
len = body.len;
- while (find_line_start("Content-Type: ", 14, &start, &len))
+ while (find_hdr_line_start("Content-Type: ", 14, &start, &len))
{
start = start + 14;
len = len - 14;
@@ -3187,7 +3233,7 @@ static int ki_remove_multibody(sip_msg_t* msg, str* content_type)
start = body.s;
len = body.len;
- while (find_line_start("Content-Type: ", 14, &start, &len))
+ while (find_hdr_line_start("Content-Type: ", 14, &start, &len))
{
end = start + 14;
len = len - 14;
@@ -3293,7 +3339,7 @@ static int ki_get_body_part_helper(sip_msg_t* msg, str* ctype, pv_spec_t *dst,
len = body.len;
/* note: header body can follow just after name: - fixit */
- while (find_line_start("Content-Type: ", 14, &start, &len))
+ while (find_hdr_line_start("Content-Type: ", 14, &start, &len))
{
end = start + 14;
len = len - 14;
URL: https://github.com/kamailio/kamailio/commit/9da83aae38199afa82d8b4eab4efd7b48d81b0b9
Author: Daniel-Constantin Mierla <***@gmail.com> Committer: Daniel-Constantin
Mierla <***@gmail.com> Date: 2021-05-31T10:44:37+02:00
Content analysis details: (-2.4 points, 5.5 required)
pts rule name description
---- ---------------------- --------------------------------------------------
-1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP
-1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1%
[score: 0.0000]
1.0 FORGED_GMAIL_RCVD 'From' gmail.com does not match 'Received'
headers
0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail
provider (miconda[at]gmail.com)
0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level
mail domains are different
0.0 DKIM_ADSP_CUSTOM_MED No valid author signature, adsp_override is
CUSTOM_MED
0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and
EnvelopeFrom freemail headers are
different
-1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list
manager
Module: kamailio
Branch: master
Commit: 9da83aae38199afa82d8b4eab4efd7b48d81b0b9
URL: https://github.com/kamailio/kamailio/commit/9da83aae38199afa82d8b4eab4efd7b48d81b0b9
Author: Daniel-Constantin Mierla <***@gmail.com>
Committer: Daniel-Constantin Mierla <***@gmail.com>
Date: 2021-05-31T10:44:37+02:00
textops: new function for finding start of a header
- use it to find Content-Type start
- GH #2748
---
Modified: src/modules/textops/textops.c
---
Diff: https://github.com/kamailio/kamailio/commit/9da83aae38199afa82d8b4eab4efd7b48d81b0b9.diff
Patch: https://github.com/kamailio/kamailio/commit/9da83aae38199afa82d8b4eab4efd7b48d81b0b9.patch
---
diff --git a/src/modules/textops/textops.c b/src/modules/textops/textops.c
index b192c1306c..cbc2309cfe 100644
--- a/src/modules/textops/textops.c
+++ b/src/modules/textops/textops.c
@@ -1597,6 +1597,52 @@ static inline int find_line_start(char *text, unsigned int text_len,
return 0;
}
+static inline int find_hdr_line_start(char *hname, unsigned int hname_len,
+ char **buf, unsigned int *buf_len)
+{
+ hdr_field_t h1;
+ hdr_field_t h2;
+ str sname;
+ char *ch, *start;
+ unsigned int len;
+
+ sname.s = hname;
+ sname.len = hname_len;
+
+ start = *buf;
+ len = *buf_len;
+ if(parse_hname2_str(&sname, &h1)==NULL) {
+ LM_ERR("not a header name: %.*s\n", hname_len, hname);
+ return 0;
+ }
+
+ while (hname_len <= len) {
+ if(parse_hname2(start, start + hname_len, &h2)!=NULL) {
+ if(h1.type>0 && h1.type==h2.type) {
+ *buf = start;
+ *buf_len = len;
+ return 1;
+ } else if(cmp_hdrname_str(&h1.name, &h2.name)==0) {
+ *buf = start;
+ *buf_len = len;
+ return 1;
+ }
+ }
+ if ((ch = memchr(start, 13, len - 1))) {
+ if (*(ch + 1) != 10) {
+ LM_ERR("No LF after CR\n");
+ return 0;
+ }
+ len = len - (ch - start + 2);
+ start = ch + 2;
+ } else {
+ LM_ERR("No CRLF found\n");
+ return 0;
+ }
+ }
+ return 0;
+}
+
/**
* return:
* 1: multipart
@@ -1645,7 +1691,7 @@ static int ki_filter_body(struct sip_msg* msg, str *content_type)
start = body.s;
len = body.len;
- while (find_line_start("Content-Type: ", 14, &start, &len))
+ while (find_hdr_line_start("Content-Type: ", 14, &start, &len))
{
start = start + 14;
len = len - 14;
@@ -3187,7 +3233,7 @@ static int ki_remove_multibody(sip_msg_t* msg, str* content_type)
start = body.s;
len = body.len;
- while (find_line_start("Content-Type: ", 14, &start, &len))
+ while (find_hdr_line_start("Content-Type: ", 14, &start, &len))
{
end = start + 14;
len = len - 14;
@@ -3293,7 +3339,7 @@ static int ki_get_body_part_helper(sip_msg_t* msg, str* ctype, pv_spec_t *dst,
len = body.len;
/* note: header body can follow just after name: - fixit */
- while (find_line_start("Content-Type: ", 14, &start, &len))
+ while (find_hdr_line_start("Content-Type: ", 14, &start, &len))
{
end = start + 14;
len = len - 14;