From 889e945d74f988e18bed04f9f44dfe709504426f Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Mon, 2 Oct 2023 18:51:28 +0100 Subject: [PATCH] ITS#10105 liblber lutil_debug: ensure msg ends with NL --- libraries/liblber/debug.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraries/liblber/debug.c b/libraries/liblber/debug.c index 1744e58a33..1f4fdbb61a 100644 --- a/libraries/liblber/debug.c +++ b/libraries/liblber/debug.c @@ -43,12 +43,15 @@ void (lutil_debug)( int debug, int level, const char *fmt, ... ) { char buffer[4096]; va_list vl; + int len; if ( !(level & debug ) ) return; va_start( vl, fmt ); - vsnprintf( buffer, sizeof(buffer), fmt, vl ); + len = vsnprintf( buffer, sizeof(buffer), fmt, vl ); va_end( vl ); + if ( len >= sizeof(buffer)-2 ) + buffer[sizeof(buffer)-2] = '\n'; ber_pvt_log_print( buffer ); } -- 2.47.3