diff options
author | Bruce Momjian <bruce@momjian.us> | 2014-04-17 12:37:53 -0400 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2014-04-17 12:37:53 -0400 |
commit | 9fe55259fd61fd9199907623f974caa7af66e780 (patch) | |
tree | 2d2d7fc333474267d375ca35db482b8a4e42e253 /contrib/pgcrypto/px-hmac.c | |
parent | 83defef8c794e7772e4099a7efa2ebac3c62742c (diff) | |
download | postgresql-9fe55259fd61fd9199907623f974caa7af66e780.tar.gz postgresql-9fe55259fd61fd9199907623f974caa7af66e780.zip |
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.
Diffstat (limited to 'contrib/pgcrypto/px-hmac.c')
-rw-r--r-- | contrib/pgcrypto/px-hmac.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/contrib/pgcrypto/px-hmac.c b/contrib/pgcrypto/px-hmac.c index 36efabd4a31..8db79233d95 100644 --- a/contrib/pgcrypto/px-hmac.c +++ b/contrib/pgcrypto/px-hmac.c @@ -75,7 +75,7 @@ hmac_init(PX_HMAC *h, const uint8 *key, unsigned klen) h->p.opad[i] = keybuf[i] ^ HMAC_OPAD; } - memset(keybuf, 0, bs); + px_memset(keybuf, 0, bs); px_free(keybuf); px_md_update(md, h->p.ipad, bs); @@ -117,7 +117,7 @@ hmac_finish(PX_HMAC *h, uint8 *dst) px_md_update(md, buf, hlen); px_md_finish(md, dst); - memset(buf, 0, hlen); + px_memset(buf, 0, hlen); px_free(buf); } @@ -129,8 +129,8 @@ hmac_free(PX_HMAC *h) bs = px_md_block_size(h->md); px_md_free(h->md); - memset(h->p.ipad, 0, bs); - memset(h->p.opad, 0, bs); + px_memset(h->p.ipad, 0, bs); + px_memset(h->p.opad, 0, bs); px_free(h->p.ipad); px_free(h->p.opad); px_free(h); |