Replace the vsprintf used in the logger with vsnprintf. (#694)

This commit is contained in:
Jett 2022-08-01 21:23:01 +01:00 committed by GitHub
parent c69d01d77b
commit c11a4a67d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,13 +26,6 @@ dLogger::~dLogger() {
}
void dLogger::vLog(const char* format, va_list args) {
const char* tempPtr = format; // strlen_s implementation for Linux and Windows
for (; *tempPtr != '\0'; ++tempPtr) {
size_t size = tempPtr - format;
if (size > 600) {
return;
}
}
#ifdef _WIN32
time_t t = time(NULL);
struct tm time;
@ -40,7 +33,7 @@ void dLogger::vLog(const char* format, va_list args) {
char timeStr[70];
strftime(timeStr, sizeof(timeStr), "%d-%m-%y %H:%M:%S", &time);
char message[2048];
vsprintf_s(message, format, args);
vsnprintf(message, 2048, format, args);
if (m_logToConsole) std::cout << "[" << timeStr << "] " << message;
mFile << "[" << timeStr << "] " << message;
@ -50,7 +43,7 @@ void dLogger::vLog(const char* format, va_list args) {
char timeStr[70];
strftime(timeStr, sizeof(timeStr), "%d-%m-%y %H:%M:%S", time);
char message[2048];
vsprintf(message, format, args);
vsnprintf(message, 2048, format, args);
if (m_logToConsole) {
fputs("[", stdout);