X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Frmr%2Fcommon%2Fsrc%2Flogging.c;h=0407eedaf89621d680aa35b371dd66404506398b;hb=9c2f0c74adb03a21646742702813b6ba4a4ae288;hp=e38d7b0e1cf7c46ec34b5dfafc843eed80ec9b36;hpb=43b7981cee870dcf523b910a3af92ccc53556b2a;p=ric-plt%2Flib%2Frmr.git diff --git a/src/rmr/common/src/logging.c b/src/rmr/common/src/logging.c index e38d7b0..0407eed 100644 --- a/src/rmr/common/src/logging.c +++ b/src/rmr/common/src/logging.c @@ -147,12 +147,17 @@ extern void rmr_vlog( int write_level, char* fmt, ... ) { memset( msg, 0, sizeof( msg ) ); // logging is slow; this ensures 0 term if msg is too large hlen = snprintf( msg, sizeof( msg ), "%ld %d/RMR [%s] ", (long) time( NULL ), log_pid, log_situations[write_level] ); + if( hlen > sizeof( msg ) - 1024 ) { // should never happen, but be parinoid + return; + } body = msg + hlen; va_start( argp, fmt ); // suss out parm past fmt vsnprintf( body, sizeof( msg ) - (hlen+2), fmt, argp ); // add in user message formatting it along the way fprintf( stderr, "%s", msg ); // we grew from printfs so all existing msg have \n; assume there + + va_end( argp ); } /* @@ -187,6 +192,8 @@ extern void rmr_vlog_force( int write_level, char* fmt, ... ) { vsnprintf( body, sizeof( msg ) - (hlen+2), fmt, argp ); // add in user message formatting it along the way fprintf( stderr, "%s", msg ); // we grew from printfs so all existing msg have \n; assume there + + va_end( argp ); } // -------------------- public functions that are needed -----------------