mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 05:27:19 +00:00
Replace the vsprintf used in the logger with vsnprintf. (#694)
This commit is contained in:
parent
c69d01d77b
commit
c11a4a67d1
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user