fix p->len to p->total_len
This commit is contained in:
2023-12-05 20:08:16 +01:00
parent f3818e805a
commit 76f3044d21

View File

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