Skip to content

libraries: Fix possible buffer/stack overflows in multiple libraries. #318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libraries/SE05X/src/lib/platform/arduino/sm_port.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void smlog_print(const char *format, ...) {
char debug_buf[1024];
va_list argptr;
va_start(argptr, format);
vsprintf(debug_buf, format, argptr);
vsnprintf(debug_buf, sizeof(debug_buf), format, argptr);
va_end(argptr);
Serial.print(debug_buf);
}
Expand Down
4 changes: 2 additions & 2 deletions libraries/SSLClient/src/ssl_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void ssl_debug_print(const char *format, ...) {
char debug_buf[1024];
va_list argptr;
va_start(argptr, format);
vsprintf(debug_buf, format, argptr);
vsnprintf(debug_buf, sizeof(debug_buf), format, argptr);
va_end(argptr);
Serial.print(debug_buf);
}
Expand All @@ -32,7 +32,7 @@ void ssl_debug_println(const char *format, ...) {
char debug_buf[1024];
va_list argptr;
va_start(argptr, format);
vsprintf(debug_buf, format, argptr);
vsnprintf(debug_buf, sizeof(debug_buf), format, argptr);
va_end(argptr);
Serial.println(debug_buf);
}
Expand Down
6 changes: 2 additions & 4 deletions libraries/WiFiS3/src/Modem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,9 @@ bool ModemClass::passthrough(const uint8_t *data, size_t size) {
/* -------------------------------------------------------------------------- */
void ModemClass::write_nowait(const string &cmd, string &str, char * fmt, ...) {
/* -------------------------------------------------------------------------- */
memset(tx_buff,0x00,MAX_BUFF_SIZE);
va_list va;
va_start (va, fmt);
vsprintf ((char *)tx_buff, fmt, va);
vsnprintf((char *)tx_buff, MAX_BUFF_SIZE, fmt, va);
va_end (va);

if(_serial_debug && _debug_level >= 2) {
Expand All @@ -109,10 +108,9 @@ void ModemClass::write_nowait(const string &cmd, string &str, char * fmt, ...) {
bool ModemClass::write(const string &prompt, string &data_res, char * fmt, ...){
/* -------------------------------------------------------------------------- */
data_res.clear();
memset(tx_buff,0x00,MAX_BUFF_SIZE);
va_list va;
va_start (va, fmt);
vsprintf ((char *)tx_buff, fmt, va);
vsnprintf((char *)tx_buff, MAX_BUFF_SIZE, fmt, va);
va_end (va);

if(_serial_debug) {
Expand Down
3 changes: 1 addition & 2 deletions libraries/lwIpWrapper/src/CNetIf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1567,10 +1567,9 @@ char b_dbg[512];
extern "C" void printDbg(const char* fmt, ...)
{

memset(b_dbg, 0x00, 256);
va_list va;
va_start(va, fmt);
vsprintf(b_dbg, fmt, va);
vsnprintf(b_dbg, sizeof(b_dbg), fmt, va);
va_end(va);

Serial.println(b_dbg);
Expand Down
Loading