From a7921157811284c652390c27b19b592ee64370f3 Mon Sep 17 00:00:00 2001 From: Nav Date: Sun, 11 Dec 2022 23:38:23 +0000 Subject: [PATCH] Added sense-check in `readMemory()` in EDBG driver, to check if the EDBG debug tool actually returned data in response to memory read command --- .../VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp index aafcc59d..f9bf225b 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp @@ -1794,7 +1794,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr throw Avr8CommandFailure("AVR8 Read memory command failed", responseFrame); } - return responseFrame.getMemoryBuffer(); + const auto data = responseFrame.getMemoryBuffer(); + + if (data.size() != bytes) { + throw Avr8CommandFailure("Unexpected number of bytes returned from EDBG debug tool"); + } + + return data; } void EdbgAvr8Interface::writeMemory(