1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-18 17:42:25 +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:
Bruce Momjian
2014-04-17 12:37:53 -04:00
parent 234283ecd3
commit a1b9c46300
22 changed files with 81 additions and 68 deletions

View File

@ -128,7 +128,7 @@ mdc_flush(PushFilter *dst, void *priv)
px_md_finish(md, pkt + 2);
res = pushf_write(dst, pkt, 2 + MDC_DIGEST_LEN);
memset(pkt, 0, 2 + MDC_DIGEST_LEN);
px_memset(pkt, 0, 2 + MDC_DIGEST_LEN);
return res;
}
@ -217,7 +217,7 @@ encrypt_free(void *priv)
{
struct EncStat *st = priv;
memset(st, 0, sizeof(*st));
px_memset(st, 0, sizeof(*st));
px_free(st);
}
@ -299,7 +299,7 @@ pkt_stream_free(void *priv)
{
struct PktStreamStat *st = priv;
memset(st, 0, sizeof(*st));
px_memset(st, 0, sizeof(*st));
px_free(st);
}
@ -490,7 +490,7 @@ write_prefix(PGP_Context *ctx, PushFilter *dst)
prefix[bs + 1] = prefix[bs - 1];
res = pushf_write(dst, prefix, bs + 2);
memset(prefix, 0, bs + 2);
px_memset(prefix, 0, bs + 2);
return res < 0 ? res : 0;
}
@ -552,7 +552,7 @@ write_symenc_sesskey(PGP_Context *ctx, PushFilter *dst)
if (res >= 0)
res = pushf_write(dst, pkt, pktlen);
memset(pkt, 0, pktlen);
px_memset(pkt, 0, pktlen);
return res;
}