Permalink
Browse files

increase the size of the buffer by 1, so the final \0 still fits, and…

… the program does not segfault during the write of the packet
  • Loading branch information...
ferrybig committed Jan 22, 2019
1 parent f1a4e2e commit a709c8c4f5b2df5f1e5847d4577cb2b5b8403feb
Showing with 2 additions and 2 deletions.
  1. +2 −2 main.c
4 main.c
@@ -420,8 +420,8 @@ void loop(state* state) {
}
if (state->fdFromServer != -1) {
if (FD_ISSET(state->fdFromServer, &fds)) {
char buf[1024];
int readLen = read(state->fdFromServer, buf, sizeof (buf));
char buf[1025];
int readLen = read(state->fdFromServer, buf, sizeof (buf) -1);
if (readLen < sizeof (buf)) {
buf[readLen] = 0;
}

0 comments on commit a709c8c

Please sign in to comment.