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';