Skip to content

Commit

Permalink
stir_shaken: return -2 if ppt Identity header is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
razvancrainea committed Mar 22, 2024
1 parent 760932e commit 7f23d8d
Showing 1 changed file with 21 additions and 24 deletions.
45 changes: 21 additions & 24 deletions modules/stir_shaken/stir_shaken.c
Original file line number Diff line number Diff line change
Expand Up @@ -1866,9 +1866,11 @@ static int get_parsed_identity(struct sip_msg *msg,

if (!(identity_hdr = get_header_by_static_name(msg, "Identity"))) {
LM_INFO("No Identity header found\n");
return -1;
return -2;
}

rc = -2;

do {

*parsed = pkg_malloc(sizeof **parsed);
Expand All @@ -1879,34 +1881,29 @@ static int get_parsed_identity(struct sip_msg *msg,
memset(*parsed, 0, sizeof **parsed);

rc = parse_identity_hf(&identity_hdr->body, *parsed);
if (rc < 0) {
pkg_free(*parsed);
*parsed = NULL;
} else {
/* check the pss type to be "shaken" */
if (str_strcmp(&(*parsed)->ppt_hdr_param, const_str(PPORT_HDR_PPT_VAL))) {
LM_INFO("Unsupported 'ppt' extension\n");
parsed_ctx_free(*parsed);
*parsed = NULL;
rc = -4; // invalid format
}
if (rc >= 0) {
if (str_strcmp(&(*parsed)->ppt_hdr_param, const_str(PPORT_HDR_PPT_VAL)) == 0)
break;
LM_INFO("Unsupported '%.*s' extension\n",
(*parsed)->ppt_hdr_param.len, (*parsed)->ppt_hdr_param.s);
rc = -2; /* consider we did not find a proper Identity header */
}

if (*parsed==NULL) {
/* let's check other Identity hdr, if present */
identity_hdr = get_next_header_by_static_name ( identity_hdr,
"Identity");
if (identity_hdr==NULL) {
LM_INFO("No valid Identity header found\n");
return rc;
}
pkg_free(*parsed);
*parsed = NULL;
/* let's check other Identity hdr, if present */
identity_hdr = get_next_header_by_static_name ( identity_hdr,
"Identity");
if (identity_hdr==NULL) {
LM_INFO("No valid Identity header found\n");
return rc;
}

}while(*parsed==NULL);
}while(rc < 0);

parsed_ctx_set(*parsed);
if (rc >= 0)
parsed_ctx_set(*parsed);

return 0;
return rc;
}

static int set_err_resp_vars(struct sip_msg *msg, pv_spec_t *err_code_var,
Expand Down

0 comments on commit 7f23d8d

Please sign in to comment.