diff options
author | Benny Prijono <bennylp@teluu.com> | 2013-10-08 09:08:13 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2013-10-08 09:08:13 +0000 |
commit | 7369d96f8361c523a7ae4753391a9a7336a89fb8 (patch) | |
tree | 64afc15371dfb0cafe15648537d33d4ad0c4c38a /pjlib/src/pj/log.c | |
parent | 476648f068a362857304aca7b383f700a304d59e (diff) |
Re #1703: fixing general bugs. First installment: correct handling of snprintf return value
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4613 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/src/pj/log.c')
-rw-r--r-- | pjlib/src/pj/log.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/pjlib/src/pj/log.c b/pjlib/src/pj/log.c index 47b6b0fc..bb808dac 100644 --- a/pjlib/src/pj/log.c +++ b/pjlib/src/pj/log.c @@ -445,6 +445,9 @@ PJ_DEF(void) pj_log( const char *sender, int level, print_len = pj_ansi_snprintf(pre, sizeof(log_buffer)-len, "<logging error: msg too long>"); } + if (print_len < 1 || print_len >= (int)(sizeof(log_buffer)-len)) { + print_len = sizeof(log_buffer) - len - 1; + } len = len + print_len; if (len > 0 && len < (int)sizeof(log_buffer)-2) { if (log_decor & PJ_LOG_HAS_CR) { |