1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-08 06:02:22 +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 d3c7498042
commit ea8725a8b3
22 changed files with 82 additions and 67 deletions

View File

@@ -40,6 +40,7 @@
#include <sys/param.h>
#include "px.h"
#include "sha2.h"
/*
@@ -570,7 +571,7 @@ SHA256_Final(uint8 digest[], SHA256_CTX *context)
}
/* Clean up state data: */
memset(context, 0, sizeof(*context));
px_memset(context, 0, sizeof(*context));
}
@@ -899,7 +900,7 @@ SHA512_Final(uint8 digest[], SHA512_CTX *context)
}
/* Zero out state data */
memset(context, 0, sizeof(*context));
px_memset(context, 0, sizeof(*context));
}
@@ -944,7 +945,7 @@ SHA384_Final(uint8 digest[], SHA384_CTX *context)
}
/* Zero out state data */
memset(context, 0, sizeof(*context));
px_memset(context, 0, sizeof(*context));
}
/*** SHA-224: *********************************************************/
@@ -987,5 +988,5 @@ SHA224_Final(uint8 digest[], SHA224_CTX *context)
}
/* Clean up state data: */
memset(context, 0, sizeof(*context));
px_memset(context, 0, sizeof(*context));
}