tcp_cmd
fix p->len to p->total_len
This commit is contained in:
@@ -369,12 +369,12 @@ err_t tcp_cmd_recv(void* arg, struct tcp_pcb* pcb, struct pbuf* p, err_t err) {
|
|||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the string is null terminated
|
if (p->tot_len >= MAX_CMD_LEN) {
|
||||||
if (p->len >= MAX_CMD_LEN) {
|
|
||||||
LOG_WARN(TAG, "Command too long");
|
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;
|
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);
|
pbuf_copy_partial(p, cmd, len, 0);
|
||||||
cmd[len] = '\0';
|
cmd[len] = '\0';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user