示例#1
0
static JSBool dnsResolve(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) {
	// Get hostname argument
	char *tmp = px_strdup(JS_GetStringBytes(JS_ValueToString(cx, argv[0])));

	// Set the default return value
	*rval = JSVAL_NULL;

	// Look it up
	struct addrinfo *info = NULL;
	if (getaddrinfo(tmp, NULL, NULL, &info))
		goto out;

	// Allocate the IP address
	px_free(tmp);
	tmp = px_malloc0(INET6_ADDRSTRLEN+1);

	// Try for IPv4 and IPv6
	if (!inet_ntop(info->ai_family,
					&((struct sockaddr_in *) info->ai_addr)->sin_addr,
					tmp, INET_ADDRSTRLEN+1) > 0)
		if (!inet_ntop(info->ai_family,
						&((struct sockaddr_in6 *) info->ai_addr)->sin6_addr,
						tmp, INET6_ADDRSTRLEN+1) > 0)
			goto out;

	// We succeeded
	*rval = STRING_TO_JSVAL(JS_NewString(cx, tmp, strlen(tmp)));
	tmp = NULL;

	out:
		if (info) freeaddrinfo(info);
		px_free(tmp);
		return true;
}
示例#2
0
文件: px.c 项目: Tao-Ma/postgres
int
px_find_combo(const char *name, PX_Combo **res)
{
	int			err;
	char	   *buf,
			   *s_cipher,
			   *s_pad;

	PX_Combo   *cx;

	cx = px_alloc(sizeof(*cx));
	memset(cx, 0, sizeof(*cx));

	buf = px_alloc(strlen(name) + 1);
	strcpy(buf, name);

	err = parse_cipher_name(buf, &s_cipher, &s_pad);
	if (err)
	{
		px_free(buf);
		px_free(cx);
		return err;
	}

	err = px_find_cipher(s_cipher, &cx->cipher);
	if (err)
		goto err1;

	if (s_pad != NULL)
	{
		if (strcmp(s_pad, "pkcs") == 0)
			cx->padding = 1;
		else if (strcmp(s_pad, "none") == 0)
			cx->padding = 0;
		else
			goto err1;
	}
	else
		cx->padding = 1;

	cx->init = combo_init;
	cx->encrypt = combo_encrypt;
	cx->decrypt = combo_decrypt;
	cx->encrypt_len = combo_encrypt_len;
	cx->decrypt_len = combo_decrypt_len;
	cx->free = combo_free;

	px_free(buf);

	*res = cx;

	return 0;

err1:
	if (cx->cipher)
		px_cipher_free(cx->cipher);
	px_free(cx);
	px_free(buf);
	return PXE_NO_CIPHER;
}
示例#3
0
static void
digest_free(PX_MD * h)
{
	EVP_MD_CTX *ctx = (EVP_MD_CTX *) h->p.ptr;

	px_free(ctx);
	px_free(h);
}
示例#4
0
static void
gen_ossl_free(PX_Cipher *c)
{
	ossldata   *od = (ossldata *) c->ptr;

	memset(od, 0, sizeof(*od));
	px_free(od);
	px_free(c);
}
示例#5
0
static void
int_sha512_free(PX_MD * h)
{
    SHA512_CTX *ctx = (SHA512_CTX *) h->p.ptr;

    memset(ctx, 0, sizeof(*ctx));
    px_free(ctx);
    px_free(h);
}
示例#6
0
static void
int_sha224_free(PX_MD *h)
{
	SHA224_CTX *ctx = (SHA224_CTX *) h->p.ptr;

	px_memset(ctx, 0, sizeof(*ctx));
	px_free(ctx);
	px_free(h);
}
static void
int_md5_free(PX_MD *h)
{
	MD5_CTX    *ctx = (MD5_CTX *) h->p.ptr;

	memset(ctx, 0, sizeof(*ctx));
	px_free(ctx);
	px_free(h);
}
示例#8
0
static void ctxs_free(ctxStore *self)
{
	if (!self) return;
	if (self->ctx) JS_DestroyContext(self->ctx);
	if (self->run) JS_DestroyRuntime(self->run);
	if (self->cls) px_free(self->cls);
	px_free(self->pac);
	px_free(self);
}
示例#9
0
static void
gen_ossl_free(PX_Cipher *c)
{
	ossldata   *od = (ossldata *) c->ptr;

	EVP_CIPHER_CTX_cleanup(&od->evp_ctx);
	px_memset(od, 0, sizeof(*od));
	px_free(od);
	px_free(c);
}
示例#10
0
static void
digest_free(PX_MD *h)
{
	OSSLDigest *digest = (OSSLDigest *) h->p.ptr;

	EVP_MD_CTX_cleanup(&digest->ctx);

	px_free(digest);
	px_free(h);
}
示例#11
0
int
mbuf_free(MBuf *mbuf)
{
	if (mbuf->own_data)
	{
		memset(mbuf->data, 0, mbuf->buf_end - mbuf->data);
		px_free(mbuf->data);
	}
	px_free(mbuf);
	return 0;
}
static void
intctx_free(PX_Cipher *c)
{
	struct int_ctx *cx = (struct int_ctx *) c->ptr;

	if (cx)
	{
		memset(cx, 0, sizeof *cx);
		px_free(cx);
	}
	px_free(c);
}
示例#13
0
static void
hmac_free(PX_HMAC *h)
{
	unsigned	bs;

	bs = px_md_block_size(h->md);
	px_md_free(h->md);

	memset(h->p.ipad, 0, bs);
	memset(h->p.opad, 0, bs);
	px_free(h->p.ipad);
	px_free(h->p.opad);
	px_free(h);
}
示例#14
0
void
pushf_free(PushFilter *mp)
{
	if (mp->op->free)
		mp->op->free(mp->priv);

	if (mp->buf)
	{
		memset(mp->buf, 0, mp->block_size);
		px_free(mp->buf);
	}

	memset(mp, 0, sizeof(*mp));
	px_free(mp);
}
示例#15
0
void
pullf_free(PullFilter *pf)
{
	if (pf->op->free)
		pf->op->free(pf->priv);

	if (pf->buf)
	{
		memset(pf->buf, 0, pf->buflen);
		px_free(pf->buf);
	}

	memset(pf, 0, sizeof(*pf));
	px_free(pf);
}
void
pgp_key_free(PGP_PubKey *pk)
{
	if (pk == NULL)
		return;

	switch (pk->algo)
	{
		case PGP_PUB_ELG_ENCRYPT:
			pgp_mpi_free(pk->pub.elg.p);
			pgp_mpi_free(pk->pub.elg.g);
			pgp_mpi_free(pk->pub.elg.y);
			pgp_mpi_free(pk->sec.elg.x);
			break;
		case PGP_PUB_RSA_SIGN:
		case PGP_PUB_RSA_ENCRYPT:
		case PGP_PUB_RSA_ENCRYPT_SIGN:
			pgp_mpi_free(pk->pub.rsa.n);
			pgp_mpi_free(pk->pub.rsa.e);
			pgp_mpi_free(pk->sec.rsa.d);
			pgp_mpi_free(pk->sec.rsa.p);
			pgp_mpi_free(pk->sec.rsa.q);
			pgp_mpi_free(pk->sec.rsa.u);
			break;
		case PGP_PUB_DSA_SIGN:
			pgp_mpi_free(pk->pub.dsa.p);
			pgp_mpi_free(pk->pub.dsa.q);
			pgp_mpi_free(pk->pub.dsa.g);
			pgp_mpi_free(pk->pub.dsa.y);
			pgp_mpi_free(pk->sec.dsa.x);
			break;
	}
	memset(pk, 0, sizeof(*pk));
	px_free(pk);
}
示例#17
0
文件: pgp-compress.c 项目: 50wu/gpdb
static int
compress_init(PushFilter *next, void *init_arg, void **priv_p)
{
	int			res;
	struct ZipStat *st;
	PGP_Context *ctx = init_arg;
	uint8		type = ctx->compress_algo;

	if (type != PGP_COMPR_ZLIB && type != PGP_COMPR_ZIP)
		return PXE_PGP_UNSUPPORTED_COMPR;

	/*
	 * init
	 */
	st = px_alloc(sizeof(*st));
	memset(st, 0, sizeof(*st));
	st->buf_len = ZIP_OUT_BUF;
	st->stream.zalloc = z_alloc;
	st->stream.zfree = z_free;

	if (type == PGP_COMPR_ZIP)
		res = deflateInit2(&st->stream, ctx->compress_level,
						   Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY);
	else
		res = deflateInit(&st->stream, ctx->compress_level);
	if (res != Z_OK)
	{
		px_free(st);
		return PXE_PGP_COMPRESSION_ERROR;
	}
	*priv_p = st;

	return ZIP_IN_BLOCK;
}
示例#18
0
文件: pgp-compress.c 项目: 50wu/gpdb
static int
decompress_init(void **priv_p, void *arg, PullFilter *src)
{
	PGP_Context *ctx = arg;
	struct DecomprData *dec;
	int			res;

	if (ctx->compress_algo != PGP_COMPR_ZLIB
		&& ctx->compress_algo != PGP_COMPR_ZIP)
		return PXE_PGP_UNSUPPORTED_COMPR;

	dec = px_alloc(sizeof(*dec));
	memset(dec, 0, sizeof(*dec));
	dec->buf_len = ZIP_OUT_BUF;
	*priv_p = dec;

	dec->stream.zalloc = z_alloc;
	dec->stream.zfree = z_free;

	if (ctx->compress_algo == PGP_COMPR_ZIP)
		res = inflateInit2(&dec->stream, -15);
	else
		res = inflateInit(&dec->stream);
	if (res != Z_OK)
	{
		px_free(dec);
		px_debug("decompress_init: inflateInit error");
		return PXE_PGP_COMPRESSION_ERROR;
	}

	return 0;
}
示例#19
0
static void
hmac_init(PX_HMAC *h, const uint8 *key, unsigned klen)
{
	unsigned	bs,
				hlen,
				i;
	uint8	   *keybuf;
	PX_MD	   *md = h->md;

	bs = px_md_block_size(md);
	hlen = px_md_result_size(md);
	keybuf = px_alloc(bs);
	memset(keybuf, 0, bs);

	if (klen > bs)
	{
		px_md_update(md, key, klen);
		px_md_finish(md, keybuf);
		px_md_reset(md);
	}
	else
		memcpy(keybuf, key, klen);

	for (i = 0; i < bs; i++)
	{
		h->p.ipad[i] = keybuf[i] ^ HMAC_IPAD;
		h->p.opad[i] = keybuf[i] ^ HMAC_OPAD;
	}

	memset(keybuf, 0, bs);
	px_free(keybuf);

	px_md_update(md, h->p.ipad, bs);
}
示例#20
0
void
pgp_cfb_free(PGP_CFB *ctx)
{
	px_cipher_free(ctx->ciph);
	px_memset(ctx, 0, sizeof(*ctx));
	px_free(ctx);
}
示例#21
0
static void
_destructor(void *s)
{
	pxMozillaPACRunnerModule * self = (pxMozillaPACRunnerModule *) s;

	ctxs_free(self->ctxs);
	px_free(self);
}
示例#22
0
//--------------------------------------------------------------------------
Hqp_IpRedSpBKP::~Hqp_IpRedSpBKP()
{
  sp_free(_CT);
  sp_free(_J);
  sp_free(_J_raw);
  px_free(_QP2J);
  px_free(_J2QP);
  px_free(_pivot);
  px_free(_blocks);
  v_free(_zw);
  v_free(_scale);
  v_free(_r12);
  v_free(_xy);
  iv_free(_CTC_degree);
  iv_free(_CTC_neigh_start);
  iv_free(_CTC_neighs);
}
示例#23
0
文件: px.c 项目: Tao-Ma/postgres
static void
combo_free(PX_Combo *cx)
{
	if (cx->cipher)
		px_cipher_free(cx->cipher);
	px_memset(cx, 0, sizeof(*cx));
	px_free(cx);
}
示例#24
0
static void
digest_free(PX_MD *h)
{
	OSSLDigest *digest = (OSSLDigest *) h->p.ptr;

	free_openssldigest(digest);
	px_free(h);
}
static void
_destructor(void *s)
{
	pxNetworkManagerNetworkModule *self = (pxNetworkManagerNetworkModule *) s;

	dbus_connection_close(self->conn);
	px_free(self);
}
示例#26
0
文件: pgp.c 项目: kevinston/postgres
int
pgp_free(PGP_Context *ctx)
{
	if (ctx->pub_key)
		pgp_key_free(ctx->pub_key);
	px_memset(ctx, 0, sizeof *ctx);
	px_free(ctx);
	return 0;
}
示例#27
0
文件: pgp-compress.c 项目: 50wu/gpdb
static void
compress_free(void *priv)
{
	struct ZipStat *st = priv;

	deflateEnd(&st->stream);
	memset(st, 0, sizeof(*st));
	px_free(st);
}
示例#28
0
int
pgp_mpi_free(PGP_MPI * mpi)
{
	if (mpi == NULL)
		return 0;
	memset(mpi, 0, sizeof(*mpi) + mpi->bytes);
	px_free(mpi);
	return 0;
}
示例#29
0
文件: pgp-compress.c 项目: 50wu/gpdb
static void
decompress_free(void *priv)
{
	struct DecomprData *dec = priv;

	inflateEnd(&dec->stream);
	memset(dec, 0, sizeof(*dec));
	px_free(dec);
}
示例#30
0
extern  int px_free_vars(PERM **vpx,...)
{
   va_list ap;
   int i=1;
   PERM **par;
   
   px_free(*vpx);
   *vpx = PNULL;
   va_start(ap, vpx);
   while (par = va_arg(ap,PERM **)) {   /* NULL ends the list*/
      px_free(*par); 
      *par = PNULL;
      i++;
   } 

   va_end(ap);
   return i;
}