MT#65601 pv_headers: add more guards

NGCP-Flow: mr12.5

Backported from the upstream master:
- c2f36a2c4f83b0ea077722ae6cc2fcecfb3616c1
- 87cfa9f3c5ae337dceb78654beb6fe4b00587993
- 25daa0445ebc611cda3e47fd34aefc74494550d7

Safe to be used, because doesn't introduce
any functional change, but makes the guarding stronger
and more proper.

Change-Id: Ie4918c0015e3c63717e037408ec437ac3b20213f
mr12.5
Donat Zenichev 2 weeks ago
parent 5b433668ad
commit e95b8c277d

@ -46,6 +46,7 @@ upstream/htable-remove-destroy-of-internal-structures-on-mod-.patch
upstream/presence-remove-destroy-of-internal-structures-on-mo.patch
upstream/pua-remove-destroy-of-internal-structures-on-mod-des.patch
upstream/tm_drop_stuck_transaction.patch
upstream/pv_headers_add_more_guards_from_upstream.patch
### relevant for upstream
sipwise/dialplan-don-t-stop-loading-rules-on-error.patch
sipwise/kamctl-TMPDIR-config.patch
@ -68,6 +69,7 @@ sipwise/permissions_consider_db_mode_when_rpc_reload.patch
sipwise/siputils_tel2sip_check_uri.patch
sipwise/dialog_w_dlg_get_var_no_error_msg.patch
sipwise/redis_dbase_no_error_msg.patch
sipwise/rtpengine_always_add_totag_to_ng_message_when_rtpp_flags.patch
### Don't just put stuff in any order
### use gbp pq import/export tooling to help maintain patches
@ -85,4 +87,4 @@ sipwise/redis_dbase_no_error_msg.patch
## git checkout -- debian/
### git commit + git-review as usual
###
sipwise/rtpengine_always_add_totag_to_ng_message_when_rtpp_flags.patch

@ -0,0 +1,53 @@
--- a/src/modules/pv_headers/pvh_func.c
+++ b/src/modules/pv_headers/pvh_func.c
@@ -111,20 +111,20 @@ int pvh_collect_headers(struct sip_msg *
val_part.len = strlen(hvals[idx]);
if(pvh_set_xavi(msg, &_pvh_params.xavi_name, &name, &val_part,
SR_XTYPE_STR, 0, 1)
- < 0)
+ == NULL)
return -1;
}
continue;
}
if(pvh_set_xavi(
msg, &_pvh_params.xavi_name, &name, &val, SR_XTYPE_STR, 0, 1)
- < 0)
+ == NULL)
return -1;
}
if(pvh_set_xavi(msg, &_pvh_params.xavi_helper_xname, &xavi_helper_name,
&_pvh_params.xavi_name, SR_XTYPE_STR, 0, 0)
- < 0)
+ == NULL)
return -1;
pvh_hdrs_set_collected(msg);
--- a/src/modules/pv_headers/pvh_str.c
+++ b/src/modules/pv_headers/pvh_str.c
@@ -48,11 +48,12 @@ int pvh_str_free(str *s)
int pvh_str_copy(str *dst, str *src, unsigned int max_size)
{
- unsigned int src_len = src->len + 1 >= max_size ? max_size - 1 : src->len;
+ unsigned int src_len = 0;
if(src == NULL || dst == NULL || src->len <= 0)
return -1;
+ src_len = src->len + 1 >= max_size ? max_size - 1 : src->len;
memset(dst->s, 0, dst->len);
memcpy(dst->s, src->s, src_len);
dst->s[src_len] = '\0';
--- a/src/modules/pv_headers/pvh_xavp.c
+++ b/src/modules/pv_headers/pvh_xavp.c
@@ -518,7 +518,7 @@ int pvh_clone_branch_xavi(struct sip_msg
if(sub->val.type == SR_XTYPE_DATA)
continue;
if(pvh_xavi_append_value(&sub->name, &sub->val, &br_xavi->val.v.xavp)
- < 0) {
+ == NULL) {
LM_ERR("cannot clone xavi %.*s\n", sub->name.len, sub->name.s);
return -1;
}
Loading…
Cancel
Save