From 76f3044d214d7c581a2fa56c854881f8029aee9d Mon Sep 17 00:00:00 2001 From: Sander Speetjens Date: Tue, 5 Dec 2023 20:08:16 +0100 Subject: [PATCH] tcp_cmd fix p->len to p->total_len --- project/Core/Src/tcp_cmd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/project/Core/Src/tcp_cmd.c b/project/Core/Src/tcp_cmd.c index d17e260..cb5c85f 100644 --- a/project/Core/Src/tcp_cmd.c +++ b/project/Core/Src/tcp_cmd.c @@ -369,12 +369,12 @@ err_t tcp_cmd_recv(void* arg, struct tcp_pcb* pcb, struct pbuf* p, err_t err) { return ERR_OK; } - // Make sure the string is null terminated - if (p->len >= MAX_CMD_LEN) { + if (p->tot_len >= MAX_CMD_LEN) { LOG_WARN(TAG, "Command too long"); + tcp_cmd_write(pcb, "Command too long"); } uint16_t len = p->tot_len >= MAX_CMD_LEN ? MAX_CMD_LEN : p->tot_len; - + // Make sure the string is null terminated pbuf_copy_partial(p, cmd, len, 0); cmd[len] = '\0';