diff --git a/src/RedirectablePrint.cpp b/src/RedirectablePrint.cpp index 9450f8990..2d6cc13ec 100644 --- a/src/RedirectablePrint.cpp +++ b/src/RedirectablePrint.cpp @@ -230,9 +230,9 @@ void RedirectablePrint::log_to_ble(const char *logLevel, const char *format, va_ auto thread = concurrency::OSThread::currentThread; meshtastic_LogRecord logRecord = meshtastic_LogRecord_init_zero; logRecord.level = getLogLevel(logLevel); - vsprintf(logRecord.message, format, arg); + vsnprintf(logRecord.message, sizeof(logRecord.message), format, arg); if (thread) - strcpy(logRecord.source, thread->ThreadName.c_str()); + strlcpy(logRecord.source, thread->ThreadName.c_str(), sizeof(logRecord.source)); logRecord.time = getValidTime(RTCQuality::RTCQualityDevice, true); auto buffer = std::unique_ptr(new uint8_t[meshtastic_LogRecord_size]); diff --git a/src/xmodem.cpp b/src/xmodem.cpp index 1d8c77760..596732975 100644 --- a/src/xmodem.cpp +++ b/src/xmodem.cpp @@ -119,7 +119,8 @@ void XModemAdapter::handlePacket(meshtastic_XModem xmodemPacket) case meshtastic_XModem_Control_STX: if ((xmodemPacket.seq == 0) && !isReceiving && !isTransmitting) { // NULL packet has the destination filename - memcpy(filename, &xmodemPacket.buffer.bytes, xmodemPacket.buffer.size); + strncpy(filename, (const char *)xmodemPacket.buffer.bytes, sizeof(filename) - 1); + filename[sizeof(filename) - 1] = '\0'; if (xmodemPacket.control == meshtastic_XModem_Control_SOH) { // Receive this file and put to Flash spiLock->lock();