Commit c755c5fd authored by Nils Larsch's avatar Nils Larsch
Browse files

improved error checking and some fixes

PR: 1170
Submitted by: Yair Elharrar
Reviewed and edited by: Nils Larsch
parent 5c8e9139
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -183,9 +183,11 @@ int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value)
	iv= ~v;
	if (!value) v=0;

	if (a == NULL)
		return 0;

	a->flags&= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); /* clear, set on write */

	if (a == NULL) return(0);
	if ((a->length < (w+1)) || (a->data == NULL))
		{
		if (!value) return(1); /* Don't need to set */
+16 −2
Original line number Diff line number Diff line
@@ -198,6 +198,11 @@ int DSA_print(BIO *bp, const DSA *x, int off)

	if (x->p)
		buf_len = (size_t)BN_num_bytes(x->p);
	else
		{
		DSAerr(DSA_F_DSA_PRINT,DSA_R_MISSING_PARAMETERS);
		goto err;
		}
	if (x->q)
		if (buf_len < (i = (size_t)BN_num_bytes(x->q)))
			buf_len = i;
@@ -670,6 +675,11 @@ int DHparams_print(BIO *bp, const DH *x)

	if (x->p)
		buf_len = (size_t)BN_num_bytes(x->p);
	else
		{
		reason = ERR_R_PASSED_NULL_PARAMETER;
		goto err;
		}
	if (x->g)
		if (buf_len < (i = (size_t)BN_num_bytes(x->g)))
			buf_len = i;
@@ -728,6 +738,11 @@ int DSAparams_print(BIO *bp, const DSA *x)

	if (x->p)
		buf_len = (size_t)BN_num_bytes(x->p);
	else
		{
		DSAerr(DSA_F_DSA_PRINT,DSA_R_MISSING_PARAMETERS);
		goto err;
		}
	if (x->q)
		if (buf_len < (i = (size_t)BN_num_bytes(x->q)))
			buf_len = i;
@@ -737,7 +752,7 @@ int DSAparams_print(BIO *bp, const DSA *x)
	m=(unsigned char *)OPENSSL_malloc(buf_len+10);
	if (m == NULL)
		{
		reason=ERR_R_MALLOC_FAILURE;
		DSAerr(DSA_F_DSA_PRINT,ERR_R_MALLOC_FAILURE);
		goto err;
		}

@@ -750,7 +765,6 @@ int DSAparams_print(BIO *bp, const DSA *x)
	ret=1;
err:
	if (m != NULL) OPENSSL_free(m);
	DSAerr(DSA_F_DSAPARAMS_PRINT,reason);
	return(ret);
	}

+7 −2
Original line number Diff line number Diff line
@@ -114,9 +114,14 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen,
	const unsigned char *pbuf;

	/* Extract useful info from parameter */
	if (param == NULL || param->type != V_ASN1_SEQUENCE ||
	    param->value.sequence == NULL) {
		EVPerr(EVP_F_PKCS5_PBE_KEYIVGEN,EVP_R_DECODE_ERROR);
		return 0;
	}

	pbuf = param->value.sequence->data;
	if (!param || (param->type != V_ASN1_SEQUENCE) ||
	   !(pbe = d2i_PBEPARAM (NULL, &pbuf, param->value.sequence->length))) {
	if (!(pbe = d2i_PBEPARAM(NULL, &pbuf, param->value.sequence->length))) {
		EVPerr(EVP_F_PKCS5_PBE_KEYIVGEN,EVP_R_DECODE_ERROR);
		return 0;
	}
+7 −2
Original line number Diff line number Diff line
@@ -156,10 +156,15 @@ int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
	const EVP_CIPHER *cipher;
	PBKDF2PARAM *kdf = NULL;

	if (param == NULL || param->type != V_ASN1_SEQUENCE ||
	    param->value.sequence == NULL) {
		EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN,EVP_R_DECODE_ERROR);
		return 0;
	}

	pbuf = param->value.sequence->data;
	plen = param->value.sequence->length;
	if(!param || (param->type != V_ASN1_SEQUENCE) ||
				   !(pbe2 = d2i_PBE2PARAM(NULL, &pbuf, plen))) {
	if(!(pbe2 = d2i_PBE2PARAM(NULL, &pbuf, plen))) {
		EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN,EVP_R_DECODE_ERROR);
		return 0;
	}
+2 −0
Original line number Diff line number Diff line
@@ -101,6 +101,8 @@ int OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm)
	{
	GENERAL_NAME *gen;
	gen = GENERAL_NAME_new();
	if (gen == NULL)
		return 0;
	if (!X509_NAME_set(&gen->d.directoryName, nm))
		{
		GENERAL_NAME_free(gen);
Loading