MT#64451 siputils: validate SIP URI produced by tel2sip and tel2sip2

After constructing the SIP URI, call parse_uri() to verify the result
is well-formed before writing it to the output pvar. If validation
fails, free the allocated pkg memory and return -1.

Change-Id: I332c54640a76d3286c2c2ae029f90550bac199c7
(cherry picked from commit 11d8e16180)
(cherry picked from commit 800b939948)
mr14.1.1
Alessio Garzi 4 weeks ago
parent 31fef3f2ee
commit 3e03cf027c

@ -50,6 +50,7 @@ sipwise/dlg_get_var_error_more_verbose_on_dlg
sipwise/db_redis_protect_length_overflow.patch
sipwise/db_redis_support_null_key_values.patch
sipwise/permissions_consider_db_mode_when_rpc_reload.patch
sipwise/siputils_tel2sip_check_uri.patch
### Don't just put stuff in any order
### use gbp pq import/export tooling to help maintain patches

@ -0,0 +1,42 @@
--- a/src/modules/siputils/checks.c
+++ b/src/modules/siputils/checks.c
@@ -645,6 +645,7 @@ int tel2sip(struct sip_msg *_msg, char *
int i, j, in_tel_parameters = 0;
pv_spec_t *res;
pv_value_t res_val;
+ struct sip_uri parsed_check;
/* get parameters */
if(get_str_fparam(&uri, _msg, (fparam_t *)_uri) < 0) {
@@ -709,6 +710,11 @@ int tel2sip(struct sip_msg *_msg, char *
/* tel_uri is not needed anymore */
pkg_free(tel_uri.s);
+ if(parse_uri(sip_uri.s, sip_uri.len, &parsed_check) < 0) {
+ pkg_free(sip_uri.s);
+ return -1;
+ }
+
/* set result pv value and write sip uri to result pv */
res_val.rs = sip_uri;
res_val.flags = PV_VAL_STR;
@@ -823,6 +829,7 @@ int tel2sip2(struct sip_msg *_msg, char
pv_value_t res_val;
char *tmp_ptr = NULL;
tel_param_t params[MAX_TEL_PARAMS];
+ struct sip_uri parsed_check;
/* get parameters */
if(get_str_fparam(&uri, _msg, (fparam_t *)_uri) < 0) {
@@ -935,6 +942,11 @@ int tel2sip2(struct sip_msg *_msg, char
/* tel_uri is not needed anymore */
pkg_free(tel_uri.s);
+ if(parse_uri(sip_uri.s, sip_uri.len, &parsed_check) < 0) {
+ pkg_free(sip_uri.s);
+ return -1;
+ }
+
sip_uri.len = strlen(sip_uri.s);
/* set result pv value and write sip uri to result pv */
Loading…
Cancel
Save