diff --git a/socketft.cpp b/socketft.cpp index 4ebc7f54..1c54f008 100644 --- a/socketft.cpp +++ b/socketft.cpp @@ -19,6 +19,10 @@ #include #endif +#if defined(CRYPTOPP_MSAN) +# include +#endif + #ifdef PREFER_WINDOWS_STYLE_SOCKETS # pragma comment(lib, "ws2_32.lib") #endif @@ -239,6 +243,10 @@ bool Socket::SendReady(const timeval *timeout) fd_set fds; FD_ZERO(&fds); FD_SET(m_s, &fds); +#ifdef CRYPTOPP_MSAN + __msan_unpoison(&fds, sizeof(fds)); +#endif + int ready; if (timeout == NULL) ready = select((int)m_s+1, NULL, &fds, NULL, NULL); @@ -256,6 +264,10 @@ bool Socket::ReceiveReady(const timeval *timeout) fd_set fds; FD_ZERO(&fds); FD_SET(m_s, &fds); +#ifdef CRYPTOPP_MSAN + __msan_unpoison(&fds, sizeof(fds)); +#endif + int ready; if (timeout == NULL) ready = select((int)m_s+1, &fds, NULL, NULL, NULL); diff --git a/wait.cpp b/wait.cpp index 43a6c275..c9078eac 100644 --- a/wait.cpp +++ b/wait.cpp @@ -20,6 +20,10 @@ #include #endif +#if defined(CRYPTOPP_MSAN) +# include +#endif + NAMESPACE_BEGIN(CryptoPP) unsigned int WaitObjectContainer::MaxWaitObjects() @@ -47,6 +51,10 @@ void WaitObjectContainer::Clear() m_maxFd = 0; FD_ZERO(&m_readfds); FD_ZERO(&m_writefds); +# ifdef CRYPTOPP_MSAN + __msan_unpoison(&m_readfds, sizeof(m_readfds)); + __msan_unpoison(&m_writefds, sizeof(m_writefds)); +# endif #endif m_noWait = false; m_firstEventTime = 0; diff --git a/wait.h b/wait.h index 5dbe8c54..622257df 100644 --- a/wait.h +++ b/wait.h @@ -18,6 +18,12 @@ #include "hrtimer.h" +#if defined(__has_feature) +# if __has_feature(memory_sanitizer) +# define CRYPTOPP_MSAN 1 +# endif +#endif + NAMESPACE_BEGIN(CryptoPP) class Tracer