make sure client_message is null terminated, prevents a buffer overflow

This commit is contained in:
xfnw 2021-08-19 17:16:02 -04:00
parent 876a56e216
commit 1d84d1eb62
1 changed files with 1 additions and 0 deletions

View File

@ -27,6 +27,7 @@ void *handle_connection(void *socket_desc) {
char *message, *command, client_message[36];
while ((read_size = recv(sock, client_message, 36, MSG_PEEK)) > 0) {
client_message[read_size] = '\0';
read_to = (char *)strchrnul(client_message, '\n')-client_message;
memset(client_message, 0, 36);
read_size = recv(sock, client_message, read_to+1, 0);