mirror of
https://github.com/postgres/postgres.git
synced 2025-07-09 22:41:56 +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:
@ -478,7 +478,7 @@ mp_int_init(mp_int z)
|
|||||||
mp_int
|
mp_int
|
||||||
mp_int_alloc(void)
|
mp_int_alloc(void)
|
||||||
{
|
{
|
||||||
mp_int out = px_alloc(sizeof(mpz_t));
|
mp_int out = palloc(sizeof(mpz_t));
|
||||||
|
|
||||||
if (out != NULL)
|
if (out != NULL)
|
||||||
mp_int_init(out);
|
mp_int_init(out);
|
||||||
@ -604,7 +604,7 @@ mp_int_free(mp_int z)
|
|||||||
assert(z != NULL);
|
assert(z != NULL);
|
||||||
|
|
||||||
mp_int_clear(z);
|
mp_int_clear(z);
|
||||||
px_free(z); /* note: NOT s_free() */
|
pfree(z); /* note: NOT s_free() */
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_result
|
mp_result
|
||||||
@ -2212,7 +2212,7 @@ static const mp_digit fill = (mp_digit) 0xdeadbeefabad1dea;
|
|||||||
static mp_digit *
|
static mp_digit *
|
||||||
s_alloc(mp_size num)
|
s_alloc(mp_size num)
|
||||||
{
|
{
|
||||||
mp_digit *out = px_alloc(num * sizeof(mp_digit));
|
mp_digit *out = palloc(num * sizeof(mp_digit));
|
||||||
|
|
||||||
assert(out != NULL);
|
assert(out != NULL);
|
||||||
|
|
||||||
@ -2235,7 +2235,7 @@ s_realloc(mp_digit *old, mp_size osize, mp_size nsize)
|
|||||||
new[ix] = fill;
|
new[ix] = fill;
|
||||||
memcpy(new, old, osize * sizeof(mp_digit));
|
memcpy(new, old, osize * sizeof(mp_digit));
|
||||||
#else
|
#else
|
||||||
mp_digit *new = px_realloc(old, nsize * sizeof(mp_digit));
|
mp_digit *new = repalloc(old, nsize * sizeof(mp_digit));
|
||||||
|
|
||||||
assert(new != NULL);
|
assert(new != NULL);
|
||||||
#endif
|
#endif
|
||||||
@ -2246,7 +2246,7 @@ s_realloc(mp_digit *old, mp_size osize, mp_size nsize)
|
|||||||
static void
|
static void
|
||||||
s_free(void *ptr)
|
s_free(void *ptr)
|
||||||
{
|
{
|
||||||
px_free(ptr);
|
pfree(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -85,8 +85,8 @@ int_sha224_free(PX_MD *h)
|
|||||||
pg_sha224_ctx *ctx = (pg_sha224_ctx *) h->p.ptr;
|
pg_sha224_ctx *ctx = (pg_sha224_ctx *) h->p.ptr;
|
||||||
|
|
||||||
px_memset(ctx, 0, sizeof(*ctx));
|
px_memset(ctx, 0, sizeof(*ctx));
|
||||||
px_free(ctx);
|
pfree(ctx);
|
||||||
px_free(h);
|
pfree(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SHA256 */
|
/* SHA256 */
|
||||||
@ -133,8 +133,8 @@ int_sha256_free(PX_MD *h)
|
|||||||
pg_sha256_ctx *ctx = (pg_sha256_ctx *) h->p.ptr;
|
pg_sha256_ctx *ctx = (pg_sha256_ctx *) h->p.ptr;
|
||||||
|
|
||||||
px_memset(ctx, 0, sizeof(*ctx));
|
px_memset(ctx, 0, sizeof(*ctx));
|
||||||
px_free(ctx);
|
pfree(ctx);
|
||||||
px_free(h);
|
pfree(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SHA384 */
|
/* SHA384 */
|
||||||
@ -181,8 +181,8 @@ int_sha384_free(PX_MD *h)
|
|||||||
pg_sha384_ctx *ctx = (pg_sha384_ctx *) h->p.ptr;
|
pg_sha384_ctx *ctx = (pg_sha384_ctx *) h->p.ptr;
|
||||||
|
|
||||||
px_memset(ctx, 0, sizeof(*ctx));
|
px_memset(ctx, 0, sizeof(*ctx));
|
||||||
px_free(ctx);
|
pfree(ctx);
|
||||||
px_free(h);
|
pfree(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SHA512 */
|
/* SHA512 */
|
||||||
@ -229,8 +229,8 @@ int_sha512_free(PX_MD *h)
|
|||||||
pg_sha512_ctx *ctx = (pg_sha512_ctx *) h->p.ptr;
|
pg_sha512_ctx *ctx = (pg_sha512_ctx *) h->p.ptr;
|
||||||
|
|
||||||
px_memset(ctx, 0, sizeof(*ctx));
|
px_memset(ctx, 0, sizeof(*ctx));
|
||||||
px_free(ctx);
|
pfree(ctx);
|
||||||
px_free(h);
|
pfree(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* init functions */
|
/* init functions */
|
||||||
@ -240,8 +240,7 @@ init_sha224(PX_MD *md)
|
|||||||
{
|
{
|
||||||
pg_sha224_ctx *ctx;
|
pg_sha224_ctx *ctx;
|
||||||
|
|
||||||
ctx = px_alloc(sizeof(*ctx));
|
ctx = palloc0(sizeof(*ctx));
|
||||||
memset(ctx, 0, sizeof(*ctx));
|
|
||||||
|
|
||||||
md->p.ptr = ctx;
|
md->p.ptr = ctx;
|
||||||
|
|
||||||
@ -260,8 +259,7 @@ init_sha256(PX_MD *md)
|
|||||||
{
|
{
|
||||||
pg_sha256_ctx *ctx;
|
pg_sha256_ctx *ctx;
|
||||||
|
|
||||||
ctx = px_alloc(sizeof(*ctx));
|
ctx = palloc0(sizeof(*ctx));
|
||||||
memset(ctx, 0, sizeof(*ctx));
|
|
||||||
|
|
||||||
md->p.ptr = ctx;
|
md->p.ptr = ctx;
|
||||||
|
|
||||||
@ -280,8 +278,7 @@ init_sha384(PX_MD *md)
|
|||||||
{
|
{
|
||||||
pg_sha384_ctx *ctx;
|
pg_sha384_ctx *ctx;
|
||||||
|
|
||||||
ctx = px_alloc(sizeof(*ctx));
|
ctx = palloc0(sizeof(*ctx));
|
||||||
memset(ctx, 0, sizeof(*ctx));
|
|
||||||
|
|
||||||
md->p.ptr = ctx;
|
md->p.ptr = ctx;
|
||||||
|
|
||||||
@ -300,8 +297,7 @@ init_sha512(PX_MD *md)
|
|||||||
{
|
{
|
||||||
pg_sha512_ctx *ctx;
|
pg_sha512_ctx *ctx;
|
||||||
|
|
||||||
ctx = px_alloc(sizeof(*ctx));
|
ctx = palloc0(sizeof(*ctx));
|
||||||
memset(ctx, 0, sizeof(*ctx));
|
|
||||||
|
|
||||||
md->p.ptr = ctx;
|
md->p.ptr = ctx;
|
||||||
|
|
||||||
|
@ -123,8 +123,8 @@ int_md5_free(PX_MD *h)
|
|||||||
MD5_CTX *ctx = (MD5_CTX *) h->p.ptr;
|
MD5_CTX *ctx = (MD5_CTX *) h->p.ptr;
|
||||||
|
|
||||||
px_memset(ctx, 0, sizeof(*ctx));
|
px_memset(ctx, 0, sizeof(*ctx));
|
||||||
px_free(ctx);
|
pfree(ctx);
|
||||||
px_free(h);
|
pfree(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SHA1 */
|
/* SHA1 */
|
||||||
@ -171,8 +171,8 @@ int_sha1_free(PX_MD *h)
|
|||||||
SHA1_CTX *ctx = (SHA1_CTX *) h->p.ptr;
|
SHA1_CTX *ctx = (SHA1_CTX *) h->p.ptr;
|
||||||
|
|
||||||
px_memset(ctx, 0, sizeof(*ctx));
|
px_memset(ctx, 0, sizeof(*ctx));
|
||||||
px_free(ctx);
|
pfree(ctx);
|
||||||
px_free(h);
|
pfree(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* init functions */
|
/* init functions */
|
||||||
@ -182,8 +182,7 @@ init_md5(PX_MD *md)
|
|||||||
{
|
{
|
||||||
MD5_CTX *ctx;
|
MD5_CTX *ctx;
|
||||||
|
|
||||||
ctx = px_alloc(sizeof(*ctx));
|
ctx = palloc0(sizeof(*ctx));
|
||||||
memset(ctx, 0, sizeof(*ctx));
|
|
||||||
|
|
||||||
md->p.ptr = ctx;
|
md->p.ptr = ctx;
|
||||||
|
|
||||||
@ -202,8 +201,7 @@ init_sha1(PX_MD *md)
|
|||||||
{
|
{
|
||||||
SHA1_CTX *ctx;
|
SHA1_CTX *ctx;
|
||||||
|
|
||||||
ctx = px_alloc(sizeof(*ctx));
|
ctx = palloc0(sizeof(*ctx));
|
||||||
memset(ctx, 0, sizeof(*ctx));
|
|
||||||
|
|
||||||
md->p.ptr = ctx;
|
md->p.ptr = ctx;
|
||||||
|
|
||||||
@ -246,9 +244,9 @@ intctx_free(PX_Cipher *c)
|
|||||||
if (cx)
|
if (cx)
|
||||||
{
|
{
|
||||||
px_memset(cx, 0, sizeof *cx);
|
px_memset(cx, 0, sizeof *cx);
|
||||||
px_free(cx);
|
pfree(cx);
|
||||||
}
|
}
|
||||||
px_free(c);
|
pfree(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -373,8 +371,7 @@ rj_load(int mode)
|
|||||||
PX_Cipher *c;
|
PX_Cipher *c;
|
||||||
struct int_ctx *cx;
|
struct int_ctx *cx;
|
||||||
|
|
||||||
c = px_alloc(sizeof *c);
|
c = palloc0(sizeof *c);
|
||||||
memset(c, 0, sizeof *c);
|
|
||||||
|
|
||||||
c->block_size = rj_block_size;
|
c->block_size = rj_block_size;
|
||||||
c->key_size = rj_key_size;
|
c->key_size = rj_key_size;
|
||||||
@ -384,8 +381,7 @@ rj_load(int mode)
|
|||||||
c->decrypt = rj_decrypt;
|
c->decrypt = rj_decrypt;
|
||||||
c->free = intctx_free;
|
c->free = intctx_free;
|
||||||
|
|
||||||
cx = px_alloc(sizeof *cx);
|
cx = palloc0(sizeof *cx);
|
||||||
memset(cx, 0, sizeof *cx);
|
|
||||||
cx->mode = mode;
|
cx->mode = mode;
|
||||||
|
|
||||||
c->ptr = cx;
|
c->ptr = cx;
|
||||||
@ -482,8 +478,7 @@ bf_load(int mode)
|
|||||||
PX_Cipher *c;
|
PX_Cipher *c;
|
||||||
struct int_ctx *cx;
|
struct int_ctx *cx;
|
||||||
|
|
||||||
c = px_alloc(sizeof *c);
|
c = palloc0(sizeof *c);
|
||||||
memset(c, 0, sizeof *c);
|
|
||||||
|
|
||||||
c->block_size = bf_block_size;
|
c->block_size = bf_block_size;
|
||||||
c->key_size = bf_key_size;
|
c->key_size = bf_key_size;
|
||||||
@ -493,8 +488,7 @@ bf_load(int mode)
|
|||||||
c->decrypt = bf_decrypt;
|
c->decrypt = bf_decrypt;
|
||||||
c->free = intctx_free;
|
c->free = intctx_free;
|
||||||
|
|
||||||
cx = px_alloc(sizeof *cx);
|
cx = palloc0(sizeof *cx);
|
||||||
memset(cx, 0, sizeof *cx);
|
|
||||||
cx->mode = mode;
|
cx->mode = mode;
|
||||||
c->ptr = cx;
|
c->ptr = cx;
|
||||||
return c;
|
return c;
|
||||||
@ -564,7 +558,7 @@ px_find_digest(const char *name, PX_MD **res)
|
|||||||
for (p = int_digest_list; p->name; p++)
|
for (p = int_digest_list; p->name; p++)
|
||||||
if (pg_strcasecmp(p->name, name) == 0)
|
if (pg_strcasecmp(p->name, name) == 0)
|
||||||
{
|
{
|
||||||
h = px_alloc(sizeof(*h));
|
h = palloc(sizeof(*h));
|
||||||
p->init(h);
|
p->init(h);
|
||||||
|
|
||||||
*res = h;
|
*res = h;
|
||||||
|
@ -70,9 +70,9 @@ mbuf_free(MBuf *mbuf)
|
|||||||
if (mbuf->own_data)
|
if (mbuf->own_data)
|
||||||
{
|
{
|
||||||
px_memset(mbuf->data, 0, mbuf->buf_end - mbuf->data);
|
px_memset(mbuf->data, 0, mbuf->buf_end - mbuf->data);
|
||||||
px_free(mbuf->data);
|
pfree(mbuf->data);
|
||||||
}
|
}
|
||||||
px_free(mbuf);
|
pfree(mbuf);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ prepare_room(MBuf *mbuf, int block_len)
|
|||||||
newlen = (mbuf->buf_end - mbuf->data)
|
newlen = (mbuf->buf_end - mbuf->data)
|
||||||
+ ((block_len + STEP + STEP - 1) & -STEP);
|
+ ((block_len + STEP + STEP - 1) & -STEP);
|
||||||
|
|
||||||
newbuf = px_realloc(mbuf->data, newlen);
|
newbuf = repalloc(mbuf->data, newlen);
|
||||||
|
|
||||||
mbuf->buf_end = newbuf + newlen;
|
mbuf->buf_end = newbuf + newlen;
|
||||||
mbuf->data_end = newbuf + (mbuf->data_end - mbuf->data);
|
mbuf->data_end = newbuf + (mbuf->data_end - mbuf->data);
|
||||||
@ -121,8 +121,8 @@ mbuf_create(int len)
|
|||||||
if (!len)
|
if (!len)
|
||||||
len = 8192;
|
len = 8192;
|
||||||
|
|
||||||
mbuf = px_alloc(sizeof *mbuf);
|
mbuf = palloc(sizeof *mbuf);
|
||||||
mbuf->data = px_alloc(len);
|
mbuf->data = palloc(len);
|
||||||
mbuf->buf_end = mbuf->data + len;
|
mbuf->buf_end = mbuf->data + len;
|
||||||
mbuf->data_end = mbuf->data;
|
mbuf->data_end = mbuf->data;
|
||||||
mbuf->read_pos = mbuf->data;
|
mbuf->read_pos = mbuf->data;
|
||||||
@ -138,7 +138,7 @@ mbuf_create_from_data(uint8 *data, int len)
|
|||||||
{
|
{
|
||||||
MBuf *mbuf;
|
MBuf *mbuf;
|
||||||
|
|
||||||
mbuf = px_alloc(sizeof *mbuf);
|
mbuf = palloc(sizeof *mbuf);
|
||||||
mbuf->data = (uint8 *) data;
|
mbuf->data = (uint8 *) data;
|
||||||
mbuf->buf_end = mbuf->data + len;
|
mbuf->buf_end = mbuf->data + len;
|
||||||
mbuf->data_end = mbuf->data + len;
|
mbuf->data_end = mbuf->data + len;
|
||||||
@ -219,15 +219,14 @@ pullf_create(PullFilter **pf_p, const PullFilterOps *op, void *init_arg, PullFil
|
|||||||
res = 0;
|
res = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pf = px_alloc(sizeof(*pf));
|
pf = palloc0(sizeof(*pf));
|
||||||
memset(pf, 0, sizeof(*pf));
|
|
||||||
pf->buflen = res;
|
pf->buflen = res;
|
||||||
pf->op = op;
|
pf->op = op;
|
||||||
pf->priv = priv;
|
pf->priv = priv;
|
||||||
pf->src = src;
|
pf->src = src;
|
||||||
if (pf->buflen > 0)
|
if (pf->buflen > 0)
|
||||||
{
|
{
|
||||||
pf->buf = px_alloc(pf->buflen);
|
pf->buf = palloc(pf->buflen);
|
||||||
pf->pos = 0;
|
pf->pos = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -248,11 +247,11 @@ pullf_free(PullFilter *pf)
|
|||||||
if (pf->buf)
|
if (pf->buf)
|
||||||
{
|
{
|
||||||
px_memset(pf->buf, 0, pf->buflen);
|
px_memset(pf->buf, 0, pf->buflen);
|
||||||
px_free(pf->buf);
|
pfree(pf->buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
px_memset(pf, 0, sizeof(*pf));
|
px_memset(pf, 0, sizeof(*pf));
|
||||||
px_free(pf);
|
pfree(pf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* may return less data than asked, 0 means eof */
|
/* may return less data than asked, 0 means eof */
|
||||||
@ -386,15 +385,14 @@ pushf_create(PushFilter **mp_p, const PushFilterOps *op, void *init_arg, PushFil
|
|||||||
res = 0;
|
res = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
mp = px_alloc(sizeof(*mp));
|
mp = palloc0(sizeof(*mp));
|
||||||
memset(mp, 0, sizeof(*mp));
|
|
||||||
mp->block_size = res;
|
mp->block_size = res;
|
||||||
mp->op = op;
|
mp->op = op;
|
||||||
mp->priv = priv;
|
mp->priv = priv;
|
||||||
mp->next = next;
|
mp->next = next;
|
||||||
if (mp->block_size > 0)
|
if (mp->block_size > 0)
|
||||||
{
|
{
|
||||||
mp->buf = px_alloc(mp->block_size);
|
mp->buf = palloc(mp->block_size);
|
||||||
mp->pos = 0;
|
mp->pos = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -415,11 +413,11 @@ pushf_free(PushFilter *mp)
|
|||||||
if (mp->buf)
|
if (mp->buf)
|
||||||
{
|
{
|
||||||
px_memset(mp->buf, 0, mp->block_size);
|
px_memset(mp->buf, 0, mp->block_size);
|
||||||
px_free(mp->buf);
|
pfree(mp->buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
px_memset(mp, 0, sizeof(*mp));
|
px_memset(mp, 0, sizeof(*mp));
|
||||||
px_free(mp);
|
pfree(mp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -156,7 +156,7 @@ digest_free(PX_MD *h)
|
|||||||
OSSLDigest *digest = (OSSLDigest *) h->p.ptr;
|
OSSLDigest *digest = (OSSLDigest *) h->p.ptr;
|
||||||
|
|
||||||
free_openssl_digest(digest);
|
free_openssl_digest(digest);
|
||||||
px_free(h);
|
pfree(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int px_openssl_initialized = 0;
|
static int px_openssl_initialized = 0;
|
||||||
@ -214,7 +214,7 @@ px_find_digest(const char *name, PX_MD **res)
|
|||||||
open_digests = digest;
|
open_digests = digest;
|
||||||
|
|
||||||
/* The PX_MD object is allocated in the current memory context. */
|
/* The PX_MD object is allocated in the current memory context. */
|
||||||
h = px_alloc(sizeof(*h));
|
h = palloc(sizeof(*h));
|
||||||
h->result_size = digest_result_size;
|
h->result_size = digest_result_size;
|
||||||
h->block_size = digest_block_size;
|
h->block_size = digest_block_size;
|
||||||
h->reset = digest_reset;
|
h->reset = digest_reset;
|
||||||
@ -353,7 +353,7 @@ gen_ossl_free(PX_Cipher *c)
|
|||||||
OSSLCipher *od = (OSSLCipher *) c->ptr;
|
OSSLCipher *od = (OSSLCipher *) c->ptr;
|
||||||
|
|
||||||
free_openssl_cipher(od);
|
free_openssl_cipher(od);
|
||||||
px_free(c);
|
pfree(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -790,7 +790,7 @@ px_find_cipher(const char *name, PX_Cipher **res)
|
|||||||
od->evp_ciph = i->ciph->cipher_func();
|
od->evp_ciph = i->ciph->cipher_func();
|
||||||
|
|
||||||
/* The PX_Cipher is allocated in current memory context */
|
/* The PX_Cipher is allocated in current memory context */
|
||||||
c = px_alloc(sizeof(*c));
|
c = palloc(sizeof(*c));
|
||||||
c->block_size = gen_ossl_block_size;
|
c->block_size = gen_ossl_block_size;
|
||||||
c->key_size = gen_ossl_key_size;
|
c->key_size = gen_ossl_key_size;
|
||||||
c->iv_size = gen_ossl_iv_size;
|
c->iv_size = gen_ossl_iv_size;
|
||||||
|
@ -67,8 +67,7 @@ pgp_cfb_create(PGP_CFB **ctx_p, int algo, const uint8 *key, int key_len,
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = px_alloc(sizeof(*ctx));
|
ctx = palloc0(sizeof(*ctx));
|
||||||
memset(ctx, 0, sizeof(*ctx));
|
|
||||||
ctx->ciph = ciph;
|
ctx->ciph = ciph;
|
||||||
ctx->block_size = px_cipher_block_size(ciph);
|
ctx->block_size = px_cipher_block_size(ciph);
|
||||||
ctx->resync = resync;
|
ctx->resync = resync;
|
||||||
@ -85,7 +84,7 @@ pgp_cfb_free(PGP_CFB *ctx)
|
|||||||
{
|
{
|
||||||
px_cipher_free(ctx->ciph);
|
px_cipher_free(ctx->ciph);
|
||||||
px_memset(ctx, 0, sizeof(*ctx));
|
px_memset(ctx, 0, sizeof(*ctx));
|
||||||
px_free(ctx);
|
pfree(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -57,13 +57,13 @@ struct ZipStat
|
|||||||
static void *
|
static void *
|
||||||
z_alloc(void *priv, unsigned n_items, unsigned item_len)
|
z_alloc(void *priv, unsigned n_items, unsigned item_len)
|
||||||
{
|
{
|
||||||
return px_alloc(n_items * item_len);
|
return palloc(n_items * item_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
z_free(void *priv, void *addr)
|
z_free(void *priv, void *addr)
|
||||||
{
|
{
|
||||||
px_free(addr);
|
pfree(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -80,8 +80,7 @@ compress_init(PushFilter *next, void *init_arg, void **priv_p)
|
|||||||
/*
|
/*
|
||||||
* init
|
* init
|
||||||
*/
|
*/
|
||||||
st = px_alloc(sizeof(*st));
|
st = palloc0(sizeof(*st));
|
||||||
memset(st, 0, sizeof(*st));
|
|
||||||
st->buf_len = ZIP_OUT_BUF;
|
st->buf_len = ZIP_OUT_BUF;
|
||||||
st->stream.zalloc = z_alloc;
|
st->stream.zalloc = z_alloc;
|
||||||
st->stream.zfree = z_free;
|
st->stream.zfree = z_free;
|
||||||
@ -93,7 +92,7 @@ compress_init(PushFilter *next, void *init_arg, void **priv_p)
|
|||||||
res = deflateInit(&st->stream, ctx->compress_level);
|
res = deflateInit(&st->stream, ctx->compress_level);
|
||||||
if (res != Z_OK)
|
if (res != Z_OK)
|
||||||
{
|
{
|
||||||
px_free(st);
|
pfree(st);
|
||||||
return PXE_PGP_COMPRESSION_ERROR;
|
return PXE_PGP_COMPRESSION_ERROR;
|
||||||
}
|
}
|
||||||
*priv_p = st;
|
*priv_p = st;
|
||||||
@ -174,7 +173,7 @@ compress_free(void *priv)
|
|||||||
|
|
||||||
deflateEnd(&st->stream);
|
deflateEnd(&st->stream);
|
||||||
px_memset(st, 0, sizeof(*st));
|
px_memset(st, 0, sizeof(*st));
|
||||||
px_free(st);
|
pfree(st);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const PushFilterOps
|
static const PushFilterOps
|
||||||
@ -212,8 +211,7 @@ decompress_init(void **priv_p, void *arg, PullFilter *src)
|
|||||||
&& ctx->compress_algo != PGP_COMPR_ZIP)
|
&& ctx->compress_algo != PGP_COMPR_ZIP)
|
||||||
return PXE_PGP_UNSUPPORTED_COMPR;
|
return PXE_PGP_UNSUPPORTED_COMPR;
|
||||||
|
|
||||||
dec = px_alloc(sizeof(*dec));
|
dec = palloc0(sizeof(*dec));
|
||||||
memset(dec, 0, sizeof(*dec));
|
|
||||||
dec->buf_len = ZIP_OUT_BUF;
|
dec->buf_len = ZIP_OUT_BUF;
|
||||||
*priv_p = dec;
|
*priv_p = dec;
|
||||||
|
|
||||||
@ -226,7 +224,7 @@ decompress_init(void **priv_p, void *arg, PullFilter *src)
|
|||||||
res = inflateInit(&dec->stream);
|
res = inflateInit(&dec->stream);
|
||||||
if (res != Z_OK)
|
if (res != Z_OK)
|
||||||
{
|
{
|
||||||
px_free(dec);
|
pfree(dec);
|
||||||
px_debug("decompress_init: inflateInit error");
|
px_debug("decompress_init: inflateInit error");
|
||||||
return PXE_PGP_COMPRESSION_ERROR;
|
return PXE_PGP_COMPRESSION_ERROR;
|
||||||
}
|
}
|
||||||
@ -318,7 +316,7 @@ decompress_free(void *priv)
|
|||||||
|
|
||||||
inflateEnd(&dec->stream);
|
inflateEnd(&dec->stream);
|
||||||
px_memset(dec, 0, sizeof(*dec));
|
px_memset(dec, 0, sizeof(*dec));
|
||||||
px_free(dec);
|
pfree(dec);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const PullFilterOps
|
static const PullFilterOps
|
||||||
|
@ -211,7 +211,7 @@ pktreader_free(void *priv)
|
|||||||
struct PktData *pkt = priv;
|
struct PktData *pkt = priv;
|
||||||
|
|
||||||
px_memset(pkt, 0, sizeof(*pkt));
|
px_memset(pkt, 0, sizeof(*pkt));
|
||||||
px_free(pkt);
|
pfree(pkt);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct PullFilterOps pktreader_filter = {
|
static struct PullFilterOps pktreader_filter = {
|
||||||
@ -224,13 +224,13 @@ pgp_create_pkt_reader(PullFilter **pf_p, PullFilter *src, int len,
|
|||||||
int pkttype, PGP_Context *ctx)
|
int pkttype, PGP_Context *ctx)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
struct PktData *pkt = px_alloc(sizeof(*pkt));
|
struct PktData *pkt = palloc(sizeof(*pkt));
|
||||||
|
|
||||||
pkt->type = pkttype;
|
pkt->type = pkttype;
|
||||||
pkt->len = len;
|
pkt->len = len;
|
||||||
res = pullf_create(pf_p, &pktreader_filter, pkt, src);
|
res = pullf_create(pf_p, &pktreader_filter, pkt, src);
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
px_free(pkt);
|
pfree(pkt);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,8 +447,7 @@ mdcbuf_init(void **priv_p, void *arg, PullFilter *src)
|
|||||||
PGP_Context *ctx = arg;
|
PGP_Context *ctx = arg;
|
||||||
struct MDCBufData *st;
|
struct MDCBufData *st;
|
||||||
|
|
||||||
st = px_alloc(sizeof(*st));
|
st = palloc0(sizeof(*st));
|
||||||
memset(st, 0, sizeof(*st));
|
|
||||||
st->buflen = sizeof(st->buf);
|
st->buflen = sizeof(st->buf);
|
||||||
st->ctx = ctx;
|
st->ctx = ctx;
|
||||||
*priv_p = st;
|
*priv_p = st;
|
||||||
@ -576,7 +575,7 @@ mdcbuf_free(void *priv)
|
|||||||
px_md_free(st->ctx->mdc_ctx);
|
px_md_free(st->ctx->mdc_ctx);
|
||||||
st->ctx->mdc_ctx = NULL;
|
st->ctx->mdc_ctx = NULL;
|
||||||
px_memset(st, 0, sizeof(*st));
|
px_memset(st, 0, sizeof(*st));
|
||||||
px_free(st);
|
pfree(st);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct PullFilterOps mdcbuf_filter = {
|
static struct PullFilterOps mdcbuf_filter = {
|
||||||
|
@ -178,8 +178,7 @@ encrypt_init(PushFilter *next, void *init_arg, void **priv_p)
|
|||||||
if (res < 0)
|
if (res < 0)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
st = px_alloc(sizeof(*st));
|
st = palloc0(sizeof(*st));
|
||||||
memset(st, 0, sizeof(*st));
|
|
||||||
st->ciph = ciph;
|
st->ciph = ciph;
|
||||||
|
|
||||||
*priv_p = st;
|
*priv_p = st;
|
||||||
@ -219,7 +218,7 @@ encrypt_free(void *priv)
|
|||||||
if (st->ciph)
|
if (st->ciph)
|
||||||
pgp_cfb_free(st->ciph);
|
pgp_cfb_free(st->ciph);
|
||||||
px_memset(st, 0, sizeof(*st));
|
px_memset(st, 0, sizeof(*st));
|
||||||
px_free(st);
|
pfree(st);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const PushFilterOps encrypt_filter = {
|
static const PushFilterOps encrypt_filter = {
|
||||||
@ -241,7 +240,7 @@ pkt_stream_init(PushFilter *next, void *init_arg, void **priv_p)
|
|||||||
{
|
{
|
||||||
struct PktStreamStat *st;
|
struct PktStreamStat *st;
|
||||||
|
|
||||||
st = px_alloc(sizeof(*st));
|
st = palloc(sizeof(*st));
|
||||||
st->final_done = 0;
|
st->final_done = 0;
|
||||||
st->pkt_block = 1 << STREAM_BLOCK_SHIFT;
|
st->pkt_block = 1 << STREAM_BLOCK_SHIFT;
|
||||||
*priv_p = st;
|
*priv_p = st;
|
||||||
@ -301,7 +300,7 @@ pkt_stream_free(void *priv)
|
|||||||
struct PktStreamStat *st = priv;
|
struct PktStreamStat *st = priv;
|
||||||
|
|
||||||
px_memset(st, 0, sizeof(*st));
|
px_memset(st, 0, sizeof(*st));
|
||||||
px_free(st);
|
pfree(st);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const PushFilterOps pkt_stream_filter = {
|
static const PushFilterOps pkt_stream_filter = {
|
||||||
|
@ -60,10 +60,10 @@ mp_px_rand(uint32 bits, mpz_t *res)
|
|||||||
int last_bits = bits & 7;
|
int last_bits = bits & 7;
|
||||||
uint8 *buf;
|
uint8 *buf;
|
||||||
|
|
||||||
buf = px_alloc(bytes);
|
buf = palloc(bytes);
|
||||||
if (!pg_strong_random(buf, bytes))
|
if (!pg_strong_random(buf, bytes))
|
||||||
{
|
{
|
||||||
px_free(buf);
|
pfree(buf);
|
||||||
return PXE_NO_RANDOM;
|
return PXE_NO_RANDOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ mp_px_rand(uint32 bits, mpz_t *res)
|
|||||||
|
|
||||||
mp_int_read_unsigned(res, buf, bytes);
|
mp_int_read_unsigned(res, buf, bytes);
|
||||||
|
|
||||||
px_free(buf);
|
pfree(buf);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ pgp_mpi_alloc(int bits, PGP_MPI **mpi)
|
|||||||
px_debug("pgp_mpi_alloc: unreasonable request: bits=%d", bits);
|
px_debug("pgp_mpi_alloc: unreasonable request: bits=%d", bits);
|
||||||
return PXE_PGP_CORRUPT_DATA;
|
return PXE_PGP_CORRUPT_DATA;
|
||||||
}
|
}
|
||||||
n = px_alloc(sizeof(*n) + len);
|
n = palloc(sizeof(*n) + len);
|
||||||
n->bits = bits;
|
n->bits = bits;
|
||||||
n->bytes = len;
|
n->bytes = len;
|
||||||
n->data = (uint8 *) (n) + sizeof(*n);
|
n->data = (uint8 *) (n) + sizeof(*n);
|
||||||
@ -72,7 +72,7 @@ pgp_mpi_free(PGP_MPI *mpi)
|
|||||||
if (mpi == NULL)
|
if (mpi == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
px_memset(mpi, 0, sizeof(*mpi) + mpi->bytes);
|
px_memset(mpi, 0, sizeof(*mpi) + mpi->bytes);
|
||||||
px_free(mpi);
|
pfree(mpi);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,12 +46,12 @@ pad_eme_pkcs1_v15(uint8 *data, int data_len, int res_len, uint8 **res_p)
|
|||||||
if (pad_len < 8)
|
if (pad_len < 8)
|
||||||
return PXE_BUG;
|
return PXE_BUG;
|
||||||
|
|
||||||
buf = px_alloc(res_len);
|
buf = palloc(res_len);
|
||||||
buf[0] = 0x02;
|
buf[0] = 0x02;
|
||||||
|
|
||||||
if (!pg_strong_random(buf + 1, pad_len))
|
if (!pg_strong_random(buf + 1, pad_len))
|
||||||
{
|
{
|
||||||
px_free(buf);
|
pfree(buf);
|
||||||
return PXE_NO_RANDOM;
|
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))
|
if (!pg_strong_random(p, 1))
|
||||||
{
|
{
|
||||||
px_memset(buf, 0, res_len);
|
px_memset(buf, 0, res_len);
|
||||||
px_free(buf);
|
pfree(buf);
|
||||||
return PXE_NO_RANDOM;
|
return PXE_NO_RANDOM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ create_secmsg(PGP_Context *ctx, PGP_MPI **msg_p, int full_bytes)
|
|||||||
/*
|
/*
|
||||||
* create "secret message"
|
* create "secret message"
|
||||||
*/
|
*/
|
||||||
secmsg = px_alloc(klen + 3);
|
secmsg = palloc(klen + 3);
|
||||||
secmsg[0] = ctx->cipher_algo;
|
secmsg[0] = ctx->cipher_algo;
|
||||||
memcpy(secmsg + 1, ctx->sess_key, klen);
|
memcpy(secmsg + 1, ctx->sess_key, klen);
|
||||||
secmsg[klen + 1] = (cksum >> 8) & 0xFF;
|
secmsg[klen + 1] = (cksum >> 8) & 0xFF;
|
||||||
@ -118,10 +118,10 @@ create_secmsg(PGP_Context *ctx, PGP_MPI **msg_p, int full_bytes)
|
|||||||
if (padded)
|
if (padded)
|
||||||
{
|
{
|
||||||
px_memset(padded, 0, full_bytes);
|
px_memset(padded, 0, full_bytes);
|
||||||
px_free(padded);
|
pfree(padded);
|
||||||
}
|
}
|
||||||
px_memset(secmsg, 0, klen + 3);
|
px_memset(secmsg, 0, klen + 3);
|
||||||
px_free(secmsg);
|
pfree(secmsg);
|
||||||
|
|
||||||
if (res >= 0)
|
if (res >= 0)
|
||||||
*msg_p = m;
|
*msg_p = m;
|
||||||
|
@ -39,8 +39,7 @@ pgp_key_alloc(PGP_PubKey **pk_p)
|
|||||||
{
|
{
|
||||||
PGP_PubKey *pk;
|
PGP_PubKey *pk;
|
||||||
|
|
||||||
pk = px_alloc(sizeof(*pk));
|
pk = palloc0(sizeof(*pk));
|
||||||
memset(pk, 0, sizeof(*pk));
|
|
||||||
*pk_p = pk;
|
*pk_p = pk;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -78,7 +77,7 @@ pgp_key_free(PGP_PubKey *pk)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
px_memset(pk, 0, sizeof(*pk));
|
px_memset(pk, 0, sizeof(*pk));
|
||||||
px_free(pk);
|
pfree(pk);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -200,8 +200,7 @@ pgp_init(PGP_Context **ctx_p)
|
|||||||
{
|
{
|
||||||
PGP_Context *ctx;
|
PGP_Context *ctx;
|
||||||
|
|
||||||
ctx = px_alloc(sizeof *ctx);
|
ctx = palloc0(sizeof *ctx);
|
||||||
memset(ctx, 0, sizeof *ctx);
|
|
||||||
|
|
||||||
ctx->cipher_algo = def_cipher_algo;
|
ctx->cipher_algo = def_cipher_algo;
|
||||||
ctx->s2k_cipher_algo = def_s2k_cipher_algo;
|
ctx->s2k_cipher_algo = def_s2k_cipher_algo;
|
||||||
@ -226,7 +225,7 @@ pgp_free(PGP_Context *ctx)
|
|||||||
if (ctx->pub_key)
|
if (ctx->pub_key)
|
||||||
pgp_key_free(ctx->pub_key);
|
pgp_key_free(ctx->pub_key);
|
||||||
px_memset(ctx, 0, sizeof *ctx);
|
px_memset(ctx, 0, sizeof *ctx);
|
||||||
px_free(ctx);
|
pfree(ctx);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,8 +57,7 @@ hmac_init(PX_HMAC *h, const uint8 *key, unsigned klen)
|
|||||||
PX_MD *md = h->md;
|
PX_MD *md = h->md;
|
||||||
|
|
||||||
bs = px_md_block_size(md);
|
bs = px_md_block_size(md);
|
||||||
keybuf = px_alloc(bs);
|
keybuf = palloc0(bs);
|
||||||
memset(keybuf, 0, bs);
|
|
||||||
|
|
||||||
if (klen > bs)
|
if (klen > bs)
|
||||||
{
|
{
|
||||||
@ -76,7 +75,7 @@ hmac_init(PX_HMAC *h, const uint8 *key, unsigned klen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
px_memset(keybuf, 0, bs);
|
px_memset(keybuf, 0, bs);
|
||||||
px_free(keybuf);
|
pfree(keybuf);
|
||||||
|
|
||||||
px_md_update(md, h->p.ipad, bs);
|
px_md_update(md, h->p.ipad, bs);
|
||||||
}
|
}
|
||||||
@ -108,7 +107,7 @@ hmac_finish(PX_HMAC *h, uint8 *dst)
|
|||||||
bs = px_md_block_size(md);
|
bs = px_md_block_size(md);
|
||||||
hlen = px_md_result_size(md);
|
hlen = px_md_result_size(md);
|
||||||
|
|
||||||
buf = px_alloc(hlen);
|
buf = palloc(hlen);
|
||||||
|
|
||||||
px_md_finish(md, buf);
|
px_md_finish(md, buf);
|
||||||
|
|
||||||
@ -118,7 +117,7 @@ hmac_finish(PX_HMAC *h, uint8 *dst)
|
|||||||
px_md_finish(md, dst);
|
px_md_finish(md, dst);
|
||||||
|
|
||||||
px_memset(buf, 0, hlen);
|
px_memset(buf, 0, hlen);
|
||||||
px_free(buf);
|
pfree(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -131,9 +130,9 @@ hmac_free(PX_HMAC *h)
|
|||||||
|
|
||||||
px_memset(h->p.ipad, 0, bs);
|
px_memset(h->p.ipad, 0, bs);
|
||||||
px_memset(h->p.opad, 0, bs);
|
px_memset(h->p.opad, 0, bs);
|
||||||
px_free(h->p.ipad);
|
pfree(h->p.ipad);
|
||||||
px_free(h->p.opad);
|
pfree(h->p.opad);
|
||||||
px_free(h);
|
pfree(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -158,9 +157,9 @@ px_find_hmac(const char *name, PX_HMAC **res)
|
|||||||
return PXE_HASH_UNUSABLE_FOR_HMAC;
|
return PXE_HASH_UNUSABLE_FOR_HMAC;
|
||||||
}
|
}
|
||||||
|
|
||||||
h = px_alloc(sizeof(*h));
|
h = palloc(sizeof(*h));
|
||||||
h->p.ipad = px_alloc(bs);
|
h->p.ipad = palloc(bs);
|
||||||
h->p.opad = px_alloc(bs);
|
h->p.opad = palloc(bs);
|
||||||
h->md = md;
|
h->md = md;
|
||||||
|
|
||||||
h->result_size = hmac_result_size;
|
h->result_size = hmac_result_size;
|
||||||
|
@ -196,8 +196,7 @@ combo_init(PX_Combo *cx, const uint8 *key, unsigned klen,
|
|||||||
ivs = px_cipher_iv_size(c);
|
ivs = px_cipher_iv_size(c);
|
||||||
if (ivs > 0)
|
if (ivs > 0)
|
||||||
{
|
{
|
||||||
ivbuf = px_alloc(ivs);
|
ivbuf = palloc0(ivs);
|
||||||
memset(ivbuf, 0, ivs);
|
|
||||||
if (ivlen > ivs)
|
if (ivlen > ivs)
|
||||||
memcpy(ivbuf, iv, ivs);
|
memcpy(ivbuf, iv, ivs);
|
||||||
else
|
else
|
||||||
@ -206,15 +205,15 @@ combo_init(PX_Combo *cx, const uint8 *key, unsigned klen,
|
|||||||
|
|
||||||
if (klen > ks)
|
if (klen > ks)
|
||||||
klen = ks;
|
klen = ks;
|
||||||
keybuf = px_alloc(ks);
|
keybuf = palloc0(ks);
|
||||||
memset(keybuf, 0, ks);
|
memset(keybuf, 0, ks);
|
||||||
memcpy(keybuf, key, klen);
|
memcpy(keybuf, key, klen);
|
||||||
|
|
||||||
err = px_cipher_init(c, keybuf, klen, ivbuf);
|
err = px_cipher_init(c, keybuf, klen, ivbuf);
|
||||||
|
|
||||||
if (ivbuf)
|
if (ivbuf)
|
||||||
px_free(ivbuf);
|
pfree(ivbuf);
|
||||||
px_free(keybuf);
|
pfree(keybuf);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -238,7 +237,7 @@ combo_encrypt(PX_Combo *cx, const uint8 *data, unsigned dlen,
|
|||||||
/* encrypt */
|
/* encrypt */
|
||||||
if (bs > 1)
|
if (bs > 1)
|
||||||
{
|
{
|
||||||
bbuf = px_alloc(bs * 4);
|
bbuf = palloc(bs * 4);
|
||||||
bpos = dlen % bs;
|
bpos = dlen % bs;
|
||||||
*rlen = dlen - bpos;
|
*rlen = dlen - bpos;
|
||||||
memcpy(bbuf, data + *rlen, bpos);
|
memcpy(bbuf, data + *rlen, bpos);
|
||||||
@ -283,7 +282,7 @@ combo_encrypt(PX_Combo *cx, const uint8 *data, unsigned dlen,
|
|||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
if (bbuf)
|
if (bbuf)
|
||||||
px_free(bbuf);
|
pfree(bbuf);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -351,7 +350,7 @@ combo_free(PX_Combo *cx)
|
|||||||
if (cx->cipher)
|
if (cx->cipher)
|
||||||
px_cipher_free(cx->cipher);
|
px_cipher_free(cx->cipher);
|
||||||
px_memset(cx, 0, sizeof(*cx));
|
px_memset(cx, 0, sizeof(*cx));
|
||||||
px_free(cx);
|
pfree(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PARSER */
|
/* PARSER */
|
||||||
@ -408,17 +407,14 @@ px_find_combo(const char *name, PX_Combo **res)
|
|||||||
|
|
||||||
PX_Combo *cx;
|
PX_Combo *cx;
|
||||||
|
|
||||||
cx = px_alloc(sizeof(*cx));
|
cx = palloc0(sizeof(*cx));
|
||||||
memset(cx, 0, sizeof(*cx));
|
buf = pstrdup(name);
|
||||||
|
|
||||||
buf = px_alloc(strlen(name) + 1);
|
|
||||||
strcpy(buf, name);
|
|
||||||
|
|
||||||
err = parse_cipher_name(buf, &s_cipher, &s_pad);
|
err = parse_cipher_name(buf, &s_cipher, &s_pad);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
px_free(buf);
|
pfree(buf);
|
||||||
px_free(cx);
|
pfree(cx);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,7 +441,7 @@ px_find_combo(const char *name, PX_Combo **res)
|
|||||||
cx->decrypt_len = combo_decrypt_len;
|
cx->decrypt_len = combo_decrypt_len;
|
||||||
cx->free = combo_free;
|
cx->free = combo_free;
|
||||||
|
|
||||||
px_free(buf);
|
pfree(buf);
|
||||||
|
|
||||||
*res = cx;
|
*res = cx;
|
||||||
|
|
||||||
@ -454,7 +450,7 @@ px_find_combo(const char *name, PX_Combo **res)
|
|||||||
err1:
|
err1:
|
||||||
if (cx->cipher)
|
if (cx->cipher)
|
||||||
px_cipher_free(cx->cipher);
|
px_cipher_free(cx->cipher);
|
||||||
px_free(cx);
|
pfree(cx);
|
||||||
px_free(buf);
|
pfree(buf);
|
||||||
return PXE_NO_CIPHER;
|
return PXE_NO_CIPHER;
|
||||||
}
|
}
|
||||||
|
@ -37,19 +37,6 @@
|
|||||||
/* keep debug messages? */
|
/* keep debug messages? */
|
||||||
#define PX_DEBUG
|
#define PX_DEBUG
|
||||||
|
|
||||||
/* a way to disable palloc
|
|
||||||
* - useful if compiled into standalone
|
|
||||||
*/
|
|
||||||
#ifndef PX_OWN_ALLOC
|
|
||||||
#define px_alloc(s) palloc(s)
|
|
||||||
#define px_realloc(p, s) repalloc(p, s)
|
|
||||||
#define px_free(p) pfree(p)
|
|
||||||
#else
|
|
||||||
void *px_alloc(size_t s);
|
|
||||||
void *px_realloc(void *p, size_t s);
|
|
||||||
void px_free(void *p);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* max salt returned */
|
/* max salt returned */
|
||||||
#define PX_MAX_SALT_LEN 128
|
#define PX_MAX_SALT_LEN 128
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user