Module: kamailio Branch: master Commit: e1006cd9e09911921728e5ce44bc5e8c1ecf3274 URL: https://github.com/kamailio/kamailio/commit/e1006cd9e09911921728e5ce44bc5e8c1ecf3274
Author: Daniel-Constantin Mierla <[email protected]> Committer: Daniel-Constantin Mierla <[email protected]> Date: 2026-05-20T11:38:45+02:00 xlog: allocate one more byte for _xlog_buf to cover xlog_auto_newline --- Modified: src/modules/xlog/xlog.c --- Diff: https://github.com/kamailio/kamailio/commit/e1006cd9e09911921728e5ce44bc5e8c1ecf3274.diff Patch: https://github.com/kamailio/kamailio/commit/e1006cd9e09911921728e5ce44bc5e8c1ecf3274.patch --- diff --git a/src/modules/xlog/xlog.c b/src/modules/xlog/xlog.c index c06c8842283..c6b3db9266b 100644 --- a/src/modules/xlog/xlog.c +++ b/src/modules/xlog/xlog.c @@ -217,7 +217,8 @@ static int mod_init(void) } } - _xlog_buf = (char *)pkg_malloc((buf_size + 1) * sizeof(char)); + /* +2 - space for ending `\0` and `\n` when xlog_auto_newline != 0 */ + _xlog_buf = (char *)pkg_malloc((buf_size + 2) * sizeof(char)); if(_xlog_buf == NULL) { PKG_MEM_ERROR; return -1; @@ -251,15 +252,16 @@ static inline int xlog_helper( char *_xlog_prefix_val = _xlog_prefix; txt.len = buf_size; - txt.s = _xlog_buf; + txt.s = _xlog_buf; /* real size: buf_size + 2 (`\n` + `\0`) */ if(xl_print_log(msg, xm->m, _xlog_buf, &txt.len) < 0) return -1; if(xlog_auto_newline != 0 && txt.len > 0 && txt.s[txt.len - 1] != '\n') { - if(txt.len < buf_size) { + if(txt.len <= buf_size) { txt.s[txt.len] = '\n'; txt.len++; + txt.s[txt.len] = '\0'; } } _______________________________________________ Kamailio - Development Mailing List -- [email protected] To unsubscribe send an email to [email protected] Important: keep the mailing list in the recipients, do not reply only to the sender!
