Corrected regression bug with validating memory addresses in GDB memory access command packets

This commit is contained in:
Nav
2022-05-04 20:47:48 +01:00
parent 4956920432
commit a28ee42239
2 changed files with 18 additions and 2 deletions

View File

@@ -75,8 +75,16 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
const auto& memoryDescriptor = memoryDescriptorsByType.at(this->memoryType);
/*
* In AVR targets, RAM is mapped to many registers and peripherals - we don't want to block GDB from
* accessing them.
*/
const auto memoryStartAddress = (this->memoryType == Targets::TargetMemoryType::RAM)
? 0x00
: memoryDescriptor.addressRange.startAddress;
if (
this->startAddress < memoryDescriptor.addressRange.startAddress
this->startAddress < memoryStartAddress
|| (this->startAddress + (this->bytes - 1)) > memoryDescriptor.addressRange.endAddress
) {
/*

View File

@@ -91,8 +91,16 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
const auto& memoryDescriptor = memoryDescriptorsByType.at(this->memoryType);
/*
* In AVR targets, RAM is mapped to many registers and peripherals - we don't want to block GDB from
* accessing them.
*/
const auto memoryStartAddress = (this->memoryType == Targets::TargetMemoryType::RAM)
? 0x00
: memoryDescriptor.addressRange.startAddress;
if (
this->startAddress < memoryDescriptor.addressRange.startAddress
this->startAddress < memoryStartAddress
|| (this->startAddress + (this->buffer.size() - 1)) > memoryDescriptor.addressRange.endAddress
) {
throw Exception(