From 37d749fe551b883b4cd89817695fd88be94307e2 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Mon, 21 Nov 2022 08:24:59 -0600 Subject: [PATCH] prefer 'vsnprintf' to 'vsprintf' (#5561) --- include/LightGBM/utils/log.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/LightGBM/utils/log.h b/include/LightGBM/utils/log.h index 6eb02fbf3a77..7cab31c15b09 100644 --- a/include/LightGBM/utils/log.h +++ b/include/LightGBM/utils/log.h @@ -109,12 +109,13 @@ class Log { } static void Fatal(const char *format, ...) { va_list val; - char str_buf[1024]; + const size_t kBufSize = 1024; + char str_buf[kBufSize]; va_start(val, format); #ifdef _MSC_VER - vsprintf_s(str_buf, format, val); + vsnprintf_s(str_buf, kBufSize, format, val); #else - vsprintf(str_buf, format, val); + vsnprintf(str_buf, kBufSize, format, val); #endif va_end(val);