aboutsummaryrefslogtreecommitdiffstats
path: root/Projects/AVRISP/Lib/V2Protocol.c
diff options
context:
space:
mode:
Diffstat (limited to 'Projects/AVRISP/Lib/V2Protocol.c')
-rw-r--r--Projects/AVRISP/Lib/V2Protocol.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/Projects/AVRISP/Lib/V2Protocol.c b/Projects/AVRISP/Lib/V2Protocol.c
index 3a1b78efd..3aa2d89ca 100644
--- a/Projects/AVRISP/Lib/V2Protocol.c
+++ b/Projects/AVRISP/Lib/V2Protocol.c
@@ -308,6 +308,18 @@ static void V2Protocol_Command_ProgramMemory(uint8_t V2Command)
Endpoint_Read_Stream_LE(&Write_Memory_Params, sizeof(Write_Memory_Params) - sizeof(Write_Memory_Params.ProgData));
Write_Memory_Params.BytesToWrite = SwapEndian_16(Write_Memory_Params.BytesToWrite);
+
+ if (Write_Memory_Params.BytesToWrite > sizeof(Write_Memory_Params.ProgData))
+ {
+ Endpoint_ClearOUT();
+ Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
+
+ Endpoint_Write_Byte(V2Command);
+ Endpoint_Write_Byte(STATUS_CMD_FAILED);
+ Endpoint_ClearIN();
+ return;
+ }
+
Endpoint_Read_Stream_LE(&Write_Memory_Params.ProgData, Write_Memory_Params.BytesToWrite);
Endpoint_ClearOUT();
@@ -407,7 +419,6 @@ static void V2Protocol_Command_ProgramMemory(uint8_t V2Command)
Endpoint_Write_Byte(V2Command);
Endpoint_Write_Byte(ProgrammingStatus);
-
Endpoint_ClearIN();
}