mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
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
This commit is contained in:
parent
8b59672d8d
commit
59b919822a
@ -32,6 +32,7 @@
|
|||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
#include "px.h"
|
#include "px.h"
|
||||||
|
#include "utils/memdebug.h"
|
||||||
|
|
||||||
/* how many bytes to ask from system random provider */
|
/* how many bytes to ask from system random provider */
|
||||||
#define RND_BYTES 32
|
#define RND_BYTES 32
|
||||||
@ -195,7 +196,7 @@ try_unix_std(uint8 *dst)
|
|||||||
memcpy(dst, (uint8 *) &x, sizeof(x));
|
memcpy(dst, (uint8 *) &x, sizeof(x));
|
||||||
dst += sizeof(x);
|
dst += sizeof(x);
|
||||||
|
|
||||||
/* let's be desperate */
|
/* hash of uninitialized stack and heap allocations */
|
||||||
res = px_find_digest("sha1", &md);
|
res = px_find_digest("sha1", &md);
|
||||||
if (res >= 0)
|
if (res >= 0)
|
||||||
{
|
{
|
||||||
@ -203,8 +204,10 @@ try_unix_std(uint8 *dst)
|
|||||||
uint8 stack[8192];
|
uint8 stack[8192];
|
||||||
int alloc = 32 * 1024;
|
int alloc = 32 * 1024;
|
||||||
|
|
||||||
|
VALGRIND_MAKE_MEM_DEFINED(stack, sizeof(stack));
|
||||||
px_md_update(md, stack, sizeof(stack));
|
px_md_update(md, stack, sizeof(stack));
|
||||||
ptr = px_alloc(alloc);
|
ptr = px_alloc(alloc);
|
||||||
|
VALGRIND_MAKE_MEM_DEFINED(ptr, alloc);
|
||||||
px_md_update(md, ptr, alloc);
|
px_md_update(md, ptr, alloc);
|
||||||
px_free(ptr);
|
px_free(ptr);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user