mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
pgcrypto: fix memset() calls that might be optimized away
Specifically, on-stack memset() might be removed, so: * Replace memset() with px_memset() * Add px_memset to copy_crlf() * Add px_memset to pgp-s2k.c Patch by Marko Kreen Report by PVS-Studio Backpatch through 8.4.
This commit is contained in:
@ -142,7 +142,7 @@ int_md5_free(PX_MD *h)
|
||||
{
|
||||
MD5_CTX *ctx = (MD5_CTX *) h->p.ptr;
|
||||
|
||||
memset(ctx, 0, sizeof(*ctx));
|
||||
px_memset(ctx, 0, sizeof(*ctx));
|
||||
px_free(ctx);
|
||||
px_free(h);
|
||||
}
|
||||
@ -190,7 +190,7 @@ int_sha1_free(PX_MD *h)
|
||||
{
|
||||
SHA1_CTX *ctx = (SHA1_CTX *) h->p.ptr;
|
||||
|
||||
memset(ctx, 0, sizeof(*ctx));
|
||||
px_memset(ctx, 0, sizeof(*ctx));
|
||||
px_free(ctx);
|
||||
px_free(h);
|
||||
}
|
||||
@ -265,7 +265,7 @@ intctx_free(PX_Cipher *c)
|
||||
|
||||
if (cx)
|
||||
{
|
||||
memset(cx, 0, sizeof *cx);
|
||||
px_memset(cx, 0, sizeof *cx);
|
||||
px_free(cx);
|
||||
}
|
||||
px_free(c);
|
||||
@ -658,7 +658,7 @@ system_reseed(void)
|
||||
skip = buf[0] >= SYSTEM_RESEED_CHANCE;
|
||||
}
|
||||
/* clear 1 byte */
|
||||
memset(buf, 0, sizeof(buf));
|
||||
px_memset(buf, 0, sizeof(buf));
|
||||
|
||||
if (skip)
|
||||
return;
|
||||
@ -668,7 +668,7 @@ system_reseed(void)
|
||||
fortuna_add_entropy(buf, n);
|
||||
|
||||
seed_time = t;
|
||||
memset(buf, 0, sizeof(buf));
|
||||
px_memset(buf, 0, sizeof(buf));
|
||||
}
|
||||
|
||||
int
|
||||
|
Reference in New Issue
Block a user