From 3605a368ea9c2d946e3f694c36dfc11c8e92b3d9 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Thu, 30 Nov 2023 22:46:01 +0100 Subject: [PATCH] src: fix write after end of buffer we hardcode `sock->buf[num_read] = '\0';` so num_read cannot be equal to the size of the buffer. Signed-off-by: Giuseppe Scrivano --- src/conn_sock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conn_sock.c b/src/conn_sock.c index 4bbe24f0..65f08779 100644 --- a/src/conn_sock.c +++ b/src/conn_sock.c @@ -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); }