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:
@ -89,7 +89,7 @@ px_crypt_md5(const char *pw, const char *salt, char *passwd, unsigned dstlen)
|
||||
px_md_update(ctx, final, pl > MD5_SIZE ? MD5_SIZE : pl);
|
||||
|
||||
/* Don't leave anything around in vm they could use. */
|
||||
memset(final, 0, sizeof final);
|
||||
px_memset(final, 0, sizeof final);
|
||||
|
||||
/* Then something really weird... */
|
||||
for (i = strlen(pw); i; i >>= 1)
|
||||
@ -154,7 +154,7 @@ px_crypt_md5(const char *pw, const char *salt, char *passwd, unsigned dstlen)
|
||||
*p = '\0';
|
||||
|
||||
/* Don't leave anything around in vm they could use. */
|
||||
memset(final, 0, sizeof final);
|
||||
px_memset(final, 0, sizeof final);
|
||||
|
||||
px_md_free(ctx1);
|
||||
px_md_free(ctx);
|
||||
|
Reference in New Issue
Block a user