[sr-dev] git:master: rtpproxy: safety check for rtp stats pv

Daniel-Constantin Mierla miconda at gmail.com
Tue Oct 9 11:41:33 CEST 2012


Module: sip-router
Branch: master
Commit: 753f511f281b0f4406908086547225c5c0bc0d23
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=753f511f281b0f4406908086547225c5c0bc0d23

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Tue Oct  9 11:39:16 2012 +0200

rtpproxy: safety check for rtp stats pv

- if the rtpproxy is not responding, there is no returned value and
  could cause crash when doing strlen(NULL)
- return $null in case of various errors, being safer to check returned
  PV value in the script against $null, rather than having undefined
  value
- reported by J. Gallart

---

 modules/rtpproxy/rtpproxy.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/modules/rtpproxy/rtpproxy.c b/modules/rtpproxy/rtpproxy.c
index 18fcb99..d2e145c 100644
--- a/modules/rtpproxy/rtpproxy.c
+++ b/modules/rtpproxy/rtpproxy.c
@@ -2610,19 +2610,20 @@ pv_get_rtpstat_f(struct sip_msg *msg, pv_param_t *param,
     str from_tag = {0, 0};
     str to_tag = {0, 0};
     struct rtpp_node *node;
-    struct iovec v[1 + 4 + 3 + 1] = {{NULL, 0}, {"Q", 1}, {" ", 1}, {NULL, 0}, {" ", 1}, {NULL, 0}, {";1 ", 3}, {";1", }, {NULL, 0}};
+    struct iovec v[1 + 4 + 3 + 1] = {{NULL, 0}, {"Q", 1}, {" ", 1}, {NULL, 0},
+		{" ", 1}, {NULL, 0}, {";1 ", 3}, {";1", }, {NULL, 0}};
 
     if (get_callid(msg, &callid) == -1 || callid.len == 0) {
         LM_ERR("can't get Call-Id field\n");
-        return -1;
+		return pv_get_null(msg, param, res);
     }
     if (get_to_tag(msg, &to_tag) == -1) {
         LM_ERR("can't get To tag\n");
-        return -1;
+		return pv_get_null(msg, param, res);
     }
     if (get_from_tag(msg, &from_tag) == -1 || from_tag.len == 0) {
         LM_ERR("can't get From tag\n");
-        return -1;
+		return pv_get_null(msg, param, res);
     }
     if(msg->id != current_msg_id){
         selected_rtpp_set = default_rtpp_set;
@@ -2649,6 +2650,8 @@ pv_get_rtpstat_f(struct sip_msg *msg, pv_param_t *param,
             nitems = 6;
     }
     ret_val.s = send_rtpp_command(node, v, nitems);
+	if(ret_val.s==NULL)
+		return pv_get_null(msg, param, res);
     ret_val.len = strlen(ret_val.s);
     return pv_get_strval(msg, param, res, &ret_val);
 }




More information about the sr-dev mailing list