Module: kamailio
Branch: 5.1
Commit: c31f33de17067cbe29042b4558f28aad59ec25f0
URL:
https://github.com/kamailio/kamailio/commit/c31f33de17067cbe29042b4558f28aa…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-12-08T16:54:21+01:00
cplc: null terminate log string
- reset field to avoid double free
(cherry picked from commit 66051f400c0a1dcd472f0c9a7957b24e9cb54a07)
---
Modified: src/modules/cplc/cpl_log.c
Modified: src/modules/cplc/cpl_time.c
---
Diff:
https://github.com/kamailio/kamailio/commit/c31f33de17067cbe29042b4558f28aa…
Patch:
https://github.com/kamailio/kamailio/commit/c31f33de17067cbe29042b4558f28aa…
---
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;
}