Don't allow overwriting end of input buffer

This commit is contained in:
Martijn Braam 2020-10-21 19:52:26 +02:00
parent dbd3648f9d
commit c57a41da43
No known key found for this signature in database
GPG Key ID: C4280ACB000B060F
1 changed files with 2 additions and 2 deletions

4
main.c
View File

@ -1118,7 +1118,7 @@ set(char *buf, size_t buf_len, int fd, int pid)
int
handle_input(int fd)
{
char buf[200];
char buf[200] = {0};
char buf2[300];
ssize_t len;
size_t pid;
@ -1131,7 +1131,7 @@ handle_input(int fd)
}
// Get the input
len = read(fd, buf, 200);
len = read(fd, buf, 199);
if (len < 0) {
printf("Read error from player %zu\n", pid);
players[pid].fd = -1;