summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorStefan Fritsch <sf@apache.org>2013-02-04 20:34:08 +0100
committerStefan Fritsch <sf@apache.org>2013-02-04 20:34:08 +0100
commit8736e6a6d00beb60c6c7744e22e17c1ccb478e56 (patch)
treee7632f4b021af3a4c00d1c06f9f562a07edd84db /modules
parentxforms (diff)
downloadapache2-8736e6a6d00beb60c6c7744e22e17c1ccb478e56.tar.xz
apache2-8736e6a6d00beb60c6c7744e22e17c1ccb478e56.zip
Avoid valgrind warnings in mod_ssl random number generator
We intentionally add uninitialized stack memory. To avoid warnings, make valgrind believe that the memory is defined. Add configure option to enable valgrind support git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1442307 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules')
-rw-r--r--modules/ssl/mod_ssl.c10
-rw-r--r--modules/ssl/ssl_engine_rand.c10
-rw-r--r--modules/ssl/ssl_private.h4
3 files changed, 24 insertions, 0 deletions
diff --git a/modules/ssl/mod_ssl.c b/modules/ssl/mod_ssl.c
index a6392d1d47..8fbc2e6ada 100644
--- a/modules/ssl/mod_ssl.c
+++ b/modules/ssl/mod_ssl.c
@@ -32,6 +32,11 @@
#include <assert.h>
+#if HAVE_VALGRIND
+#include <valgrind.h>
+int ssl_running_on_valgrind = 0;
+#endif
+
/*
* the table of configuration directives we provide
*/
@@ -347,6 +352,11 @@ static int ssl_hook_pre_config(apr_pool_t *pconf,
apr_pool_t *plog,
apr_pool_t *ptemp)
{
+
+#if HAVE_VALGRIND
+ ssl_running_on_valgrind = RUNNING_ON_VALGRIND;
+#endif
+
/* We must register the library in full, to ensure our configuration
* code can successfully test the SSL environment.
*/
diff --git a/modules/ssl/ssl_engine_rand.c b/modules/ssl/ssl_engine_rand.c
index df25d8fd63..a5893e1561 100644
--- a/modules/ssl/ssl_engine_rand.c
+++ b/modules/ssl/ssl_engine_rand.c
@@ -29,6 +29,11 @@
#include "ssl_private.h"
+#if HAVE_VALGRIND
+#include <valgrind.h>
+#include <memcheck.h>
+#endif
+
/* _________________________________________________________________
**
** Support for better seeding of SSL library's RNG
@@ -113,6 +118,11 @@ int ssl_rand_seed(server_rec *s, apr_pool_t *p, ssl_rsctx_t nCtx, char *prefix)
/*
* seed in some current state of the run-time stack (128 bytes)
*/
+#if HAVE_VALGRIND
+ if (ssl_running_on_valgrind) {
+ VALGRIND_MAKE_MEM_DEFINED(stackdata, sizeof(stackdata));
+ }
+#endif
n = ssl_rand_choosenum(0, sizeof(stackdata)-128-1);
RAND_seed(stackdata+n, 128);
nDone += 128;
diff --git a/modules/ssl/ssl_private.h b/modules/ssl/ssl_private.h
index 3ff3014bba..edcd1d8050 100644
--- a/modules/ssl/ssl_private.h
+++ b/modules/ssl/ssl_private.h
@@ -1024,6 +1024,10 @@ OCSP_RESPONSE *modssl_dispatch_ocsp_request(const apr_uri_t *uri,
conn_rec *c, apr_pool_t *p);
#endif
+#if HAVE_VALGRIND
+extern int ssl_running_on_valgrind;
+#endif
+
#endif /* SSL_PRIVATE_H */
/** @} */