From 88c2d67d88c99f85af31f5679cba5634c354eb7e Mon Sep 17 00:00:00 2001 From: Obe Van Lierde Date: Mon, 27 Nov 2023 00:37:32 +0100 Subject: [PATCH] first buffer overflow --- project/Core/Src/modbus_tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Core/Src/modbus_tcp.c b/project/Core/Src/modbus_tcp.c index b3aaec5..4fcadb0 100644 --- a/project/Core/Src/modbus_tcp.c +++ b/project/Core/Src/modbus_tcp.c @@ -62,7 +62,7 @@ static err_t modbus_incoming_data(void* arg, struct tcp_pcb* pcb, struct pbuf* p tcp_recved(pcb, p->tot_len); pc = (char*)p->payload; - for (uint16_t i = 0; i < MAX_REG; i++) { // Putting the buffer in the register array + for (uint16_t i = 0; i < p->tot_len && i < MAX_REG; i++) { // Putting the buffer in the register array registers[i] = pc[i]; // Getting the error "void value not ignored as it ought to be" on this line }