From 371b8ef26403a277a784810c0aa597eaa48a20f7 Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Tue, 23 Jul 2019 08:40:42 +0200 Subject: event buffer valgrind memcheck support Signed-off-by: Toni Uhlig --- src/jail.c | 4 ++-- src/pevent.h | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/jail.c b/src/jail.c index feb3bc2..5671499 100644 --- a/src/jail.c +++ b/src/jail.c @@ -480,8 +480,8 @@ static int jail_childfn(prisoner_process *ctx) goto finalise; } - N("Socket to tty I/O for prisoner pid %d", - child_pid); + N("Socket to tty I/O for prisoner pid for fd %d: %d", + master_fd, child_pid); if (jail_socket_tty(ctx, master_fd)) E_STRERR("Socket to tty I/O for prisoner pid %d", child_pid); diff --git a/src/pevent.h b/src/pevent.h index 585fc46..129db05 100644 --- a/src/pevent.h +++ b/src/pevent.h @@ -38,6 +38,9 @@ #include #include #include +#ifdef HAVE_VALGRIND +#include +#endif #include "socket.h" @@ -117,6 +120,11 @@ static inline ssize_t event_buf_read(event_buf *read_buf) event_buf_avail(read_buf)); if (siz > 0) read_buf->buf_used += siz; +#ifdef HAVE_VALGRIND + VALGRIND_MAKE_MEM_UNDEFINED(read_buf->buf + read_buf->buf_used, + sizeof(read_buf->buf)*sizeof(read_buf->buf[0]) - + read_buf->buf_used); +#endif return siz; } @@ -126,6 +134,11 @@ static inline void event_buf_discard(event_buf *input, size_t siz) memmove(input->buf + siz, input->buf, input->buf_used - siz); input->buf_used -= siz; } +#ifdef HAVE_VALGRIND + VALGRIND_MAKE_MEM_UNDEFINED(input->buf + input->buf_used, + sizeof(input->buf)*sizeof(input->buf[0]) - + input->buf_used); +#endif } static inline void event_buf_discardall(event_buf *input) -- cgit v1.2.3