mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Remove custom memory allocation layer in pgcrypto
PX_OWN_ALLOC was intended as a way to disable the use of palloc(), and
over the time new palloc() or equivalent calls have been added like in
32984d8
, making this extra layer losing its original purpose. This
simplifies on the way some code paths to use palloc0() rather than
palloc() followed by memset(0).
Author: Daniel Gustafsson
Discussion: https://postgr.es/m/A5BFAA1A-B2E8-4CBC-895E-7B1B9475A527@yesql.se
This commit is contained in:
@ -46,12 +46,12 @@ pad_eme_pkcs1_v15(uint8 *data, int data_len, int res_len, uint8 **res_p)
|
||||
if (pad_len < 8)
|
||||
return PXE_BUG;
|
||||
|
||||
buf = px_alloc(res_len);
|
||||
buf = palloc(res_len);
|
||||
buf[0] = 0x02;
|
||||
|
||||
if (!pg_strong_random(buf + 1, pad_len))
|
||||
{
|
||||
px_free(buf);
|
||||
pfree(buf);
|
||||
return PXE_NO_RANDOM;
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ pad_eme_pkcs1_v15(uint8 *data, int data_len, int res_len, uint8 **res_p)
|
||||
if (!pg_strong_random(p, 1))
|
||||
{
|
||||
px_memset(buf, 0, res_len);
|
||||
px_free(buf);
|
||||
pfree(buf);
|
||||
return PXE_NO_RANDOM;
|
||||
}
|
||||
}
|
||||
@ -97,7 +97,7 @@ create_secmsg(PGP_Context *ctx, PGP_MPI **msg_p, int full_bytes)
|
||||
/*
|
||||
* create "secret message"
|
||||
*/
|
||||
secmsg = px_alloc(klen + 3);
|
||||
secmsg = palloc(klen + 3);
|
||||
secmsg[0] = ctx->cipher_algo;
|
||||
memcpy(secmsg + 1, ctx->sess_key, klen);
|
||||
secmsg[klen + 1] = (cksum >> 8) & 0xFF;
|
||||
@ -118,10 +118,10 @@ create_secmsg(PGP_Context *ctx, PGP_MPI **msg_p, int full_bytes)
|
||||
if (padded)
|
||||
{
|
||||
px_memset(padded, 0, full_bytes);
|
||||
px_free(padded);
|
||||
pfree(padded);
|
||||
}
|
||||
px_memset(secmsg, 0, klen + 3);
|
||||
px_free(secmsg);
|
||||
pfree(secmsg);
|
||||
|
||||
if (res >= 0)
|
||||
*msg_p = m;
|
||||
|
Reference in New Issue
Block a user