tcp_cmd
Make sure p->payload is null terminated
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user