1
0
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:
Bruce Momjian
2014-04-17 12:37:53 -04:00
parent 83defef8c7
commit 9fe55259fd
22 changed files with 82 additions and 67 deletions

View File

@ -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);