From 269d417601717dd277a4b2b6be5e959f4334bbc3 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 16 Jun 2015 20:23:17 +0000 Subject: [PATCH] scst_debug(): Avoid that debug_print_with_prefix() overflows the output buffer Detected by Coverity. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6339 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scst/src/scst_debug.c b/scst/src/scst_debug.c index 40b8f54dd..88acf74e9 100644 --- a/scst/src/scst_debug.c +++ b/scst/src/scst_debug.c @@ -75,11 +75,11 @@ int debug_print_with_prefix(unsigned long trace_flag, const char *severity, spin_lock_irqsave(&trace_buf_lock, flags); - strcpy(trace_buf, severity); + strlcpy(trace_buf, severity, TRACE_BUF_SIZE); i = strlen(trace_buf); if (trace_flag & TRACE_PID) - i += snprintf(&trace_buf[i], TRACE_BUF_SIZE, "[%d]: ", pid); + i += snprintf(&trace_buf[i], TRACE_BUF_SIZE - i, "[%d]: ", pid); if (prefix != NULL) i += snprintf(&trace_buf[i], TRACE_BUF_SIZE - i, "%s: ", prefix);