Fix stack dynamic buffer overflow in the logging lib
parent
3109ec13c0
commit
54fdeb1ad5
|
@ -61,8 +61,9 @@ namespace blt::logging {
|
||||||
};
|
};
|
||||||
|
|
||||||
void applyFormatting(const std::string& format, std::string& output, va_list& args){
|
void applyFormatting(const std::string& format, std::string& output, va_list& args){
|
||||||
char formattedChars[format.length()];
|
const char* fmt_c_str = format.c_str();
|
||||||
vsprintf(formattedChars, format.c_str(), args);
|
char formattedChars[1+std::vsnprintf(nullptr, 0, fmt_c_str, args)];
|
||||||
|
vsprintf(formattedChars, fmt_c_str, args);
|
||||||
output = std::string(formattedChars);
|
output = std::string(formattedChars);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue