Make sure p->payload is null terminated
This commit is contained in:
2023-11-30 00:29:19 +01:00
parent 56846b7643
commit 6ceee577de

View File

@@ -202,6 +202,11 @@ static err_t tcp_cmd_recv_new(void* arg, struct tcp_pcb* pcb, struct pbuf* p, er
tcp_recved(pcb, p->tot_len);
char* next;
// Make sure the string is null terminated
p->payload = realloc(p->payload, p->len + 1);
p->tot_len = p->len + 1;
((char*)(p->payload))[p->len] = '\0';
remove_newline((char*)(p->payload));
// Split string into tokens by delimiter (space)
argv[0] = get_next_token((char*)(p->payload), " ", &next);