From b1ecb1484c00a0bb1a8cdb4e285b3cf92a1e4489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6kt=C3=BCrk=20Y=C3=BCksek?= Date: Tue, 15 Feb 2022 20:58:38 -0500 Subject: [PATCH v1 1/1] Platform/Unix/Process.cpp: remove calls to std::vector::clear() The method std::vector::clear() is meant to remove all elements and set the size to 0. After calling this method, attempting to access an element in the vector using operator[] triggers an assertion in glibc that is designed to catch accesses to empty vectors at runtime. Instead, use the fill constructor to initialize buffers with 0 as one would do with memset and not call clear() on them. This ensure that the size and capacity remains the same, while preventing potential information leakage. Bug: https://bugs.gentoo.org/833444 --- src/Platform/Unix/Process.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Platform/Unix/Process.cpp b/src/Platform/Unix/Process.cpp index d148a68..9d961da 100644 --- a/src/Platform/Unix/Process.cpp +++ b/src/Platform/Unix/Process.cpp @@ -118,11 +118,7 @@ namespace VeraCrypt throw_sys_if (fcntl (errPipe.GetReadFD(), F_SETFL, O_NONBLOCK) == -1); throw_sys_if (fcntl (exceptionPipe.GetReadFD(), F_SETFL, O_NONBLOCK) == -1); - vector buffer (4096), stdOutput (4096), errOutput (4096), exOutput (4096); - buffer.clear (); - stdOutput.clear (); - errOutput.clear (); - exOutput.clear (); + vector buffer (4096, 0), stdOutput (4096, 0), errOutput (4096, 0), exOutput (4096, 0); Poller poller (outPipe.GetReadFD(), errPipe.GetReadFD(), exceptionPipe.GetReadFD()); int status, waitRes; -- 2.33.1