Module: kamailio
Branch: master
Commit: 66051f400c0a1dcd472f0c9a7957b24e9cb54a07
URL: 
https://github.com/kamailio/kamailio/commit/66051f400c0a1dcd472f0c9a7957b24e9cb54a07

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2017-12-08T16:50:51+01:00

cplc: null terminate log string

- reset field to avoid double free

---

Modified: src/modules/cplc/cpl_log.c
Modified: src/modules/cplc/cpl_time.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/66051f400c0a1dcd472f0c9a7957b24e9cb54a07.diff
Patch: 
https://github.com/kamailio/kamailio/commit/66051f400c0a1dcd472f0c9a7957b24e9cb54a07.patch

---

diff --git a/src/modules/cplc/cpl_log.c b/src/modules/cplc/cpl_log.c
index 195b11c7b7..39ad19b32f 100644
--- a/src/modules/cplc/cpl_log.c
+++ b/src/modules/cplc/cpl_log.c
@@ -84,7 +84,7 @@ void compile_logs( str *log)
                log->len += cpl_logs[i].len;
 
        /* get a buffer */
-       log->s = (char*)pkg_malloc(log->len);
+       log->s = (char*)pkg_malloc(log->len+1);
        if (log->s==0) {
                LM_ERR("no more pkg mem\n");
                log->len = 0;
@@ -97,6 +97,7 @@ void compile_logs( str *log)
                memcpy( p, cpl_logs[i].s, cpl_logs[i].len);
                p += cpl_logs[i].len;
        }
+       log->s[log->len] = '\0';
 
        return;
 }
diff --git a/src/modules/cplc/cpl_time.c b/src/modules/cplc/cpl_time.c
index 36758f8e19..653c3a2352 100644
--- a/src/modules/cplc/cpl_time.c
+++ b/src/modules/cplc/cpl_time.c
@@ -328,6 +328,7 @@ int tr_byxxx_init(tr_byxxx_p _bxp, int _nr)
        if(!_bxp->req)
        {
                pkg_free(_bxp->xxx);
+               _bxp->xxx = NULL;
                return -1;
        }
        


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

Reply via email to