Skip to content

Commit

Permalink
src: fix write after end of buffer
Browse files Browse the repository at this point in the history
we hardcode `sock->buf[num_read] = '\0';` so num_read cannot be equal
to the size of the buffer.

Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Nov 30, 2023
1 parent 633ac6b commit 3605a36
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/conn_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ static gboolean read_remote_sock(struct remote_sock_s *sock)
}

if (SOCK_IS_STREAM(sock->sock_type)) {
num_read = read(sock->fd, sock->buf, CONN_SOCK_BUF_SIZE);
num_read = read(sock->fd, sock->buf, CONN_SOCK_BUF_SIZE - 1);
} else {
num_read = recvfrom(sock->fd, sock->buf, CONN_SOCK_BUF_SIZE - 1, 0, NULL, NULL);
}
Expand Down

0 comments on commit 3605a36

Please sign in to comment.