Adds some support for valgrind helpers

This patch adds an option to compile freerdp in a valgrind compliant way.
The purpose is to ease memchecking when connecting with TLS. We mark bytes
retrieved from SSL_read() as plainly defined to prevent the undefined contamination.
With the patch and the option activated you get a single warning at connection
during the handshake, and nothing after.
This commit is contained in:
Hardening 2014-05-12 18:01:29 +02:00
parent 8abc0edd3f
commit 729c24cedb
4 changed files with 19 additions and 0 deletions

View File

@ -345,6 +345,12 @@ if(NOT WIN32)
list(REMOVE_ITEM CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
endif()
if(WITH_VALGRIND_MEMCHECK)
check_include_files(valgrind/memcheck.h HAVE_VALGRIND_MEMCHECK_H)
else()
unset(HAVE_VALGRIND_MEMCHECK_H CACHE)
endif()
if(UNIX OR CYGWIN)
check_include_files(sys/eventfd.h HAVE_AIO_H)
check_include_files(sys/eventfd.h HAVE_EVENTFD_H)

View File

@ -44,6 +44,10 @@ if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_COMPILER_IS_CLANG 1)
endif()
if(NOT WIN32)
option(WITH_VALGRIND_MEMCHECK "Compile with valgrind helpers." OFF)
endif()
if(MSVC)
option(WITH_NATIVE_SSPI "Use native SSPI modules" ON)
option(WITH_WINMM "Use Windows Multimedia" ON)

View File

@ -25,6 +25,7 @@
#cmakedefine HAVE_TM_GMTOFF
#cmakedefine HAVE_AIO_H
#cmakedefine HAVE_PTHREAD_GNU_EXT
#cmakedefine HAVE_VALGRIND_MEMCHECK_H
/* Options */

View File

@ -31,6 +31,10 @@
#include <freerdp/crypto/tls.h>
#ifdef HAVE_VALGRIND_MEMCHECK_H
#include <valgrind/memcheck.h>
#endif
static CryptoCert tls_get_certificate(rdpTls* tls, BOOL peer)
{
CryptoCert cert;
@ -465,6 +469,10 @@ int tls_read(rdpTls* tls, BYTE* data, int length)
}
}
#ifdef HAVE_VALGRIND_MEMCHECK_H
VALGRIND_MAKE_MEM_DEFINED(data, status);
#endif
return status;
}