Skip to content
Open
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
7 changes: 7 additions & 0 deletions source/application/luaport.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ static volatile char repl_buffer[BLE_PREFERRED_MAX_MTU];

void lua_write_to_repl(uint8_t *buffer, uint8_t length)
{
// Bounds check to prevent buffer overflow (CVE-PENDING)
// Buffer size is BLE_PREFERRED_MAX_MTU (247), length can be 0-255
if (length >= BLE_PREFERRED_MAX_MTU)
{
length = BLE_PREFERRED_MAX_MTU - 1; // Reserve space for null terminator
}

// Loop copy because memcpy isn't compatible with volatile
for (size_t buffer_index = 0; buffer_index < length; buffer_index++)
{
Expand Down