From ea8725a8b376b46324b47616432670769cae95ed Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Thu, 17 Apr 2014 12:37:53 -0400 Subject: 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. --- contrib/pgcrypto/pgp-encrypt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'contrib/pgcrypto/pgp-encrypt.c') diff --git a/contrib/pgcrypto/pgp-encrypt.c b/contrib/pgcrypto/pgp-encrypt.c index 3b9b5d20edf..48eb3f42af0 100644 --- a/contrib/pgcrypto/pgp-encrypt.c +++ b/contrib/pgcrypto/pgp-encrypt.c @@ -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; } -- cgit v1.2.3