summaryrefslogtreecommitdiff
path: root/lib/libcrypto
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2015-02-14 15:28:40 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2015-02-14 15:28:40 +0000
commitb9ce846303d68f83a954c2f0bf4f85e9a74a961f (patch)
treeddac86a46c94cc3f8f618cb61957973d9befdbed /lib/libcrypto
parentf595c9044efc08cec1f5674ad9a5e687d4de38c5 (diff)
Memory leak upon error in X509_add1_{trust,reject}_object.
ok doug@
Diffstat (limited to 'lib/libcrypto')
-rw-r--r--lib/libcrypto/asn1/x_x509a.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/lib/libcrypto/asn1/x_x509a.c b/lib/libcrypto/asn1/x_x509a.c
index c0624d674b0..29817915b61 100644
--- a/lib/libcrypto/asn1/x_x509a.c
+++ b/lib/libcrypto/asn1/x_x509a.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: x_x509a.c,v 1.13 2015/02/11 04:00:39 jsing Exp $ */
+/* $OpenBSD: x_x509a.c,v 1.14 2015/02/14 15:28:39 miod Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 1999.
*/
@@ -214,13 +214,21 @@ X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj)
{
X509_CERT_AUX *aux;
ASN1_OBJECT *objtmp;
+ int rc;
+
if (!(objtmp = OBJ_dup(obj)))
return 0;
if (!(aux = aux_get(x)))
- return 0;
+ goto err;
if (!aux->trust && !(aux->trust = sk_ASN1_OBJECT_new_null()))
- return 0;
- return sk_ASN1_OBJECT_push(aux->trust, objtmp);
+ goto err;
+ rc = sk_ASN1_OBJECT_push(aux->trust, objtmp);
+ if (rc != 0)
+ return rc;
+
+err:
+ ASN1_OBJECT_free(objtmp);
+ return 0;
}
int
@@ -228,13 +236,21 @@ X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj)
{
X509_CERT_AUX *aux;
ASN1_OBJECT *objtmp;
+ int rc;
+
if (!(objtmp = OBJ_dup(obj)))
return 0;
if (!(aux = aux_get(x)))
- return 0;
+ goto err;
if (!aux->reject && !(aux->reject = sk_ASN1_OBJECT_new_null()))
- return 0;
- return sk_ASN1_OBJECT_push(aux->reject, objtmp);
+ goto err;
+ rc = sk_ASN1_OBJECT_push(aux->reject, objtmp);
+ if (rc != 0)
+ return rc;
+
+err:
+ ASN1_OBJECT_free(objtmp);
+ return 0;
}
void