Module: kamailio
Branch: master
Commit: 95d56e986e90b0d9a7527d7fa026cb510b41d9c5
URL: 
https://github.com/kamailio/kamailio/commit/95d56e986e90b0d9a7527d7fa026cb510b41d9c5

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2018-11-19T10:01:21+01:00

siptrace: convert status code to string using static buffer function

---

Modified: src/modules/siptrace/siptrace.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/95d56e986e90b0d9a7527d7fa026cb510b41d9c5.diff
Patch: 
https://github.com/kamailio/kamailio/commit/95d56e986e90b0d9a7527d7fa026cb510b41d9c5.patch

---

diff --git a/src/modules/siptrace/siptrace.c b/src/modules/siptrace/siptrace.c
index d1d32661fa..7de96b4b5d 100644
--- a/src/modules/siptrace/siptrace.c
+++ b/src/modules/siptrace/siptrace.c
@@ -1136,7 +1136,7 @@ static void trace_onreply_in(struct cell *t, int type, 
struct tmcb_params *ps)
        siptrace_data_t sto;
        sip_msg_t *msg;
        sip_msg_t *req;
-       char statusbuf[8];
+       char statusbuf[INT2STR_MAX_LEN];
 
        if(t == NULL || t->uas.request == 0 || ps == NULL) {
                LM_DBG("no uas request, local transaction\n");
@@ -1170,8 +1170,11 @@ static void trace_onreply_in(struct cell *t, int type, 
struct tmcb_params *ps)
 
        sto.method = get_cseq(msg)->method;
 
-       strcpy(statusbuf, int2str(ps->code, &sto.status.len));
-       sto.status.s = statusbuf;
+       sto.status.s = int2strbuf(ps->code, statusbuf, INT2STR_MAX_LEN, 
&sto.status.len);
+       if(sto.status.s == 0) {
+               LM_ERR("failure to get the status string\n");
+               return;
+       }
 
        sto.fromip.len = snprintf(sto.fromip_buff, SIPTRACE_ADDR_MAX, 
"%s:%s:%d",
                        siptrace_proto_name(msg->rcv.proto),
@@ -1218,7 +1221,7 @@ static void trace_onreply_out(struct cell *t, int type, 
struct tmcb_params *ps)
        struct sip_msg *msg;
        struct sip_msg *req;
        struct ip_addr to_ip;
-       char statusbuf[8];
+       char statusbuf[INT2STR_MAX_LEN];
        dest_info_t *dst;
 
        if(t == NULL || t->uas.request == 0 || ps == NULL) {
@@ -1293,8 +1296,11 @@ static void trace_onreply_out(struct cell *t, int type, 
struct tmcb_params *ps)
                }
        }
 
-       strcpy(statusbuf, int2str(ps->code, &sto.status.len));
-       sto.status.s = statusbuf;
+       sto.status.s = int2strbuf(ps->code, statusbuf, INT2STR_MAX_LEN, 
&sto.status.len);
+       if(sto.status.s == 0) {
+               LM_ERR("failure to get the status string\n");
+               return;
+       }
 
        memset(&to_ip, 0, sizeof(struct ip_addr));
        dst = ps->dst;
@@ -1341,7 +1347,7 @@ static void trace_sl_onreply_out(sl_cbp_t *slcbp)
        siptrace_data_t sto;
        sip_msg_t *msg;
        ip_addr_t to_ip;
-       char statusbuf[5];
+       char statusbuf[INT2STR_MAX_LEN];
 
        if(slcbp == NULL || slcbp->req == NULL) {
                LM_ERR("bad parameters\n");
@@ -1385,8 +1391,11 @@ static void trace_sl_onreply_out(sl_cbp_t *slcbp)
                }
        }
 
-       strcpy(statusbuf, int2str(slcbp->code, &sto.status.len));
-       sto.status.s = statusbuf;
+       sto.status.s = int2strbuf(slcbp->code, statusbuf, INT2STR_MAX_LEN, 
&sto.status.len);
+       if(sto.status.s == 0) {
+               LM_ERR("failure to get the status string\n");
+               return;
+       }
 
        memset(&to_ip, 0, sizeof(struct ip_addr));
        if(slcbp->dst == 0) {


_______________________________________________
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to