diff --git a/tests/tcp_cmd.cpp b/tests/tcp_cmd.cpp index 00ed0fa..b3e2bc2 100644 --- a/tests/tcp_cmd.cpp +++ b/tests/tcp_cmd.cpp @@ -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);