X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/489515fbbf0f61ae63bcdd4b858a5fe59e90c0be..064e6a2f32719da5b7ed2ff3a8a32c5788e753d0:/Projects/AVRISP/Lib/V2Protocol.c?ds=sidebyside 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(); }