Don't allow overwriting end of input buffer
This commit is contained in:
parent
dbd3648f9d
commit
c57a41da43
4
main.c
4
main.c
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue