Commit d2aea038 authored by Dr. Stephen Henson's avatar Dr. Stephen Henson
Browse files

Memory leak and NULL dereference fixes.

PR#3403
parent 3b3b69ab
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -394,6 +394,8 @@ int chopup_args(ARGS *arg, char *buf, int *argc, char **argv[])
		{
		arg->count=20;
		arg->data=(char **)OPENSSL_malloc(sizeof(char *)*arg->count);
		if (arg->data == NULL)
			return 0;
		}
	for (i=0; i<arg->count; i++)
		arg->data[i]=NULL;
@@ -1663,6 +1665,8 @@ char *make_config_name()

	len=strlen(t)+strlen(OPENSSL_CONF)+2;
	p=OPENSSL_malloc(len);
	if (p == NULL)
		return NULL;
	BUF_strlcpy(p,t,len);
#ifndef OPENSSL_SYS_VMS
	BUF_strlcat(p,"/",len);
+3 −0
Original line number Diff line number Diff line
@@ -2800,6 +2800,9 @@ char *make_revocation_str(int rev_type, char *rev_arg)

	revtm = X509_gmtime_adj(NULL, 0);

	if (!revtm)
		return NULL;

	i = revtm->length + 1;

	if (reason) i += strlen(reason) + 1;
+7 −1
Original line number Diff line number Diff line
@@ -141,7 +141,13 @@ int MAIN(int argc, char **argv)
			{
			if (--argc < 1) goto bad;
			if(!certflst) certflst = sk_OPENSSL_STRING_new_null();
			sk_OPENSSL_STRING_push(certflst,*(++argv));
			if (!certflst)
				goto end;
			if (!sk_OPENSSL_STRING_push(certflst,*(++argv)))
				{
				sk_OPENSSL_STRING_free(certflst);
				goto end;
				}
			}
		else
			{
+14 −5
Original line number Diff line number Diff line
@@ -240,24 +240,29 @@ ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
	struct tm *ts;
	struct tm data;
	size_t len = 20;
	int free_s = 0;

	if (s == NULL)
		{
		free_s = 1;
		s=M_ASN1_UTCTIME_new();
		}
	if (s == NULL)
		return(NULL);
		goto err;


	ts=OPENSSL_gmtime(&t, &data);
	if (ts == NULL)
		return(NULL);
		goto err;

	if (offset_day || offset_sec)
		{ 
		if (!OPENSSL_gmtime_adj(ts, offset_day, offset_sec))
			return NULL;
			goto err;
		}

	if((ts->tm_year < 50) || (ts->tm_year >= 150))
		return NULL;
		goto err;

	p=(char *)s->data;
	if ((p == NULL) || ((size_t)s->length < len))
@@ -266,7 +271,7 @@ ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
		if (p == NULL)
			{
			ASN1err(ASN1_F_ASN1_UTCTIME_ADJ,ERR_R_MALLOC_FAILURE);
			return(NULL);
			goto err;
			}
		if (s->data != NULL)
			OPENSSL_free(s->data);
@@ -281,6 +286,10 @@ ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t,
	ebcdic2ascii(s->data, s->data, s->length);
#endif
	return(s);
	err:
	if (free_s && s)
		M_ASN1_UTCTIME_free(s);
	return NULL;
	}


+6 −1
Original line number Diff line number Diff line
@@ -262,7 +262,12 @@ int EVP_PKEY_asn1_add_alias(int to, int from)
	if (!ameth)
		return 0;
	ameth->pkey_base_id = to;
	return EVP_PKEY_asn1_add0(ameth);
	if (!EVP_PKEY_asn1_add0(ameth))
		{
		EVP_PKEY_asn1_free(ameth);
		return 0;
		}
	return 1;
	}

int EVP_PKEY_asn1_get0_info(int *ppkey_id, int *ppkey_base_id, int *ppkey_flags,
Loading