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

@ -77,7 +77,7 @@ pgp_key_free(PGP_PubKey *pk)
pgp_mpi_free(pk->sec.dsa.x);
break;
}
memset(pk, 0, sizeof(*pk));
px_memset(pk, 0, sizeof(*pk));
px_free(pk);
}
@ -150,7 +150,7 @@ calc_key_id(PGP_PubKey *pk)
px_md_free(md);
memcpy(pk->key_id, hash + 12, 8);
memset(hash, 0, 20);
px_memset(hash, 0, 20);
return 0;
}
@ -291,8 +291,8 @@ check_key_sha1(PullFilter *src, PGP_PubKey *pk)
res = PXE_PGP_KEYPKT_CORRUPT;
}
err:
memset(got_sha1, 0, 20);
memset(my_sha1, 0, 20);
px_memset(got_sha1, 0, 20);
px_memset(my_sha1, 0, 20);
return res;
}