Skip to content

Commit

Permalink
Fixed parameter passing for dr_is_gw().
Browse files Browse the repository at this point in the history
If partitions are not used, do a logic shift for the parameters with one position to the left to compensate the missing partition param.

Reported by Jonathan Hunter <hunterj91@hotmail.com>

(cherry picked from commit 963f051)
  • Loading branch information
bogdan-iancu committed Jan 11, 2018
1 parent f71f6f3 commit d448ab6
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions modules/drouting/drouting.c
Expand Up @@ -4325,29 +4325,32 @@ static int goes_to_gw_0(struct sip_msg* msg)
/*
* Checks if a variable (containing a SIP URI) is a GW; tests the TYPE too
*/
static int dr_is_gw(struct sip_msg* msg, char * part, char* src_pv, char* type_s,
char* flags_pv, char* gw_att)
static int dr_is_gw(struct sip_msg* msg, char * part, char* src_pv,
char* type_s, char* flags_pv, char* gw_att)
{
pv_value_t src;

if(use_partitions) {
gw_attrs_spec = (pv_spec_p)gw_att;
if ( pv_get_spec_value(msg, (pv_spec_p)src_pv, &src)!=0 ||
(src.flags&PV_VAL_STR)==0 || src.rs.len<=0) {
LM_ERR("failed to get string value for src\n");
return -1;
}
return _is_dr_uri_gw(msg, part, flags_pv, !type_s ? -1:(int)(long)type_s, &src.rs);
gw_attrs_spec = (pv_spec_p)gw_att;
return _is_dr_uri_gw(msg, part, flags_pv,
!type_s ? -1:(int)(long)type_s, &src.rs);
}
else {
/* shift (as meaning) all parameters to the left one position (as
* there is no partition parameter */
if ( pv_get_spec_value(msg, (pv_spec_p)part, &src)!=0 ||
(src.flags&PV_VAL_STR)==0 || src.rs.len<=0) {
LM_ERR("failed to get string value for src\n");
return -1;
}
gw_attrs_spec = (pv_spec_p)flags_pv;
return _is_dr_uri_gw(msg, NULL, flags_pv ,!type_s ? -1:(int)(long)type_s
,&src.rs);
return _is_dr_uri_gw(msg, NULL, type_s ,!src_pv ? -1:(int)(long)src_pv,
&src.rs);
}
}

Expand Down

0 comments on commit d448ab6

Please sign in to comment.