Discussion:
[sr-dev] git:master:cb2705f2: textops: check for HDR_ERROR_T after header name parsing
Daniel-Constantin Mierla
2021-06-02 19:23:38 UTC
Permalink
Content preview: Module: kamailio Branch: master Commit: cb2705f21e56f884e733febc2362055da3ef2693
URL: https://github.com/kamailio/kamailio/commit/cb2705f21e56f884e733febc2362055da3ef2693
Author: Daniel-Constantin Mierla <***@gmail.com> Committer: Daniel-Constantin
Mierla <***@gmail.com> Date: 2021-06-02T21:21:59+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]
0.0 DKIM_ADSP_CUSTOM_MED No valid author signature, adsp_override is
CUSTOM_MED
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
1.0 FORGED_GMAIL_RCVD 'From' gmail.com does not match 'Received'
headers
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: cb2705f21e56f884e733febc2362055da3ef2693
URL: https://github.com/kamailio/kamailio/commit/cb2705f21e56f884e733febc2362055da3ef2693

Author: Daniel-Constantin Mierla <***@gmail.com>
Committer: Daniel-Constantin Mierla <***@gmail.com>
Date: 2021-06-02T21:21:59+02:00

textops: check for HDR_ERROR_T after header name parsing

---

Modified: src/modules/textops/textops.c

---

Diff: https://github.com/kamailio/kamailio/commit/cb2705f21e56f884e733febc2362055da3ef2693.diff
Patch: https://github.com/kamailio/kamailio/commit/cb2705f21e56f884e733febc2362055da3ef2693.patch

---

diff --git a/src/modules/textops/textops.c b/src/modules/textops/textops.c
index 40ea02c273..e93bc82bf2 100644
--- a/src/modules/textops/textops.c
+++ b/src/modules/textops/textops.c
@@ -1816,7 +1816,8 @@ static int ki_remove_hf_idx(sip_msg_t* msg, str* hname, int idx)
return -1;
}

- if(parse_hname2_str(hname, &hfm)==NULL) {
+ parse_hname2_str(hname, &hfm);
+ if(hfm.type==HDR_ERROR_T) {
LM_ERR("failed to parse header name [%.*s]\n", hname->len, hname->s);
return -1;
}
@@ -2098,12 +2099,13 @@ static int ki_hname_gparam(str *hname, gparam_t *gp)

gp->v.str = *hname;

- if (parse_hname2_short(hbuf, hbuf + gp->v.str.len + 1, &hdr)==0) {
+ parse_hname2_short(hbuf, hbuf + gp->v.str.len + 1, &hdr);
+ if(hdr.type==HDR_ERROR_T) {
LM_ERR("error parsing header name: %.*s\n", hname->len, hname->s);
return -1;
}

- if (hdr.type!=HDR_OTHER_T && hdr.type!=HDR_ERROR_T) {
+ if (hdr.type!=HDR_OTHER_T) {
LM_DBG("using hdr type (%d) instead of <%.*s>\n",
hdr.type, gp->v.str.len, gp->v.str.s);
gp->v.str.s = NULL;
@@ -3713,17 +3715,19 @@ static int hname_fixup(void** param, int param_no)
gp->v.str.s[gp->v.str.len] = ':';
gp->v.str.len++;

- if (parse_hname2_short(gp->v.str.s, gp->v.str.s + gp->v.str.len, &hdr)==0)
+ parse_hname2_short(gp->v.str.s, gp->v.str.s + gp->v.str.len, &hdr);
+
+ gp->v.str.len--;
+ gp->v.str.s[gp->v.str.len] = c;
+
+ if(hdr.type==HDR_ERROR_T)
{
LM_ERR("error parsing header name\n");
pkg_free(gp);
return E_UNSPEC;
}

- gp->v.str.len--;
- gp->v.str.s[gp->v.str.len] = c;
-
- if (hdr.type!=HDR_OTHER_T && hdr.type!=HDR_ERROR_T)
+ if (hdr.type!=HDR_OTHER_T)
{
LM_DBG("using hdr type (%d) instead of <%.*s>\n",
hdr.type, gp->v.str.len, gp->v.str.s);

Loading...