diff options
author | Noah Misch <noah@leadboat.com> | 2015-02-02 10:00:45 -0500 |
---|---|---|
committer | Noah Misch <noah@leadboat.com> | 2015-02-02 10:00:45 -0500 |
commit | 59b919822ab060f721e235964d19b55a19c815f0 (patch) | |
tree | 3106d0fd46d4e7c23c0079de2dd43980dbd1cc43 | |
parent | 8b59672d8d23ea4203cf2701d126a96edca5bdd6 (diff) | |
download | postgresql-59b919822ab060f721e235964d19b55a19c815f0.tar.gz postgresql-59b919822ab060f721e235964d19b55a19c815f0.zip |
Prevent Valgrind Memcheck errors around px_acquire_system_randomness().
This function uses uninitialized stack and heap buffers as supplementary
entropy sources. Mark them so Memcheck will not complain. Back-patch
to 9.4, where Valgrind Memcheck cooperation first appeared.
Marko Tiikkaja
-rw-r--r-- | contrib/pgcrypto/random.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/contrib/pgcrypto/random.c b/contrib/pgcrypto/random.c index 3f092ca3461..d72679e412d 100644 --- a/contrib/pgcrypto/random.c +++ b/contrib/pgcrypto/random.c @@ -32,6 +32,7 @@ #include "postgres.h" #include "px.h" +#include "utils/memdebug.h" /* how many bytes to ask from system random provider */ #define RND_BYTES 32 @@ -195,7 +196,7 @@ try_unix_std(uint8 *dst) memcpy(dst, (uint8 *) &x, sizeof(x)); dst += sizeof(x); - /* let's be desperate */ + /* hash of uninitialized stack and heap allocations */ res = px_find_digest("sha1", &md); if (res >= 0) { @@ -203,8 +204,10 @@ try_unix_std(uint8 *dst) uint8 stack[8192]; int alloc = 32 * 1024; + VALGRIND_MAKE_MEM_DEFINED(stack, sizeof(stack)); px_md_update(md, stack, sizeof(stack)); ptr = px_alloc(alloc); + VALGRIND_MAKE_MEM_DEFINED(ptr, alloc); px_md_update(md, ptr, alloc); px_free(ptr); |