summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2015-02-14 15:17:00 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2015-02-14 15:17:00 +0000
commit40167684d4729200d3addc6fde92410ff147fbe5 (patch)
tree442660d90d6ca801c235de21045e4e28088a3473
parent2b6c675edc38389860a94567ed2199d891a8c098 (diff)
Check i2d_name_canon() for failure (negative return). Coverity CID 78888.
ok doug@ jsing@
-rw-r--r--lib/libssl/src/crypto/asn1/x_name.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/libssl/src/crypto/asn1/x_name.c b/lib/libssl/src/crypto/asn1/x_name.c
index 910110505d2..c69c35534d0 100644
--- a/lib/libssl/src/crypto/asn1/x_name.c
+++ b/lib/libssl/src/crypto/asn1/x_name.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: x_name.c,v 1.26 2015/02/11 04:00:39 jsing Exp $ */
+/* $OpenBSD: x_name.c,v 1.27 2015/02/14 15:16:59 miod Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -422,7 +422,7 @@ x509_name_canon(X509_NAME *a)
STACK_OF(STACK_OF_X509_NAME_ENTRY) *intname = NULL;
STACK_OF(X509_NAME_ENTRY) *entries = NULL;
X509_NAME_ENTRY *entry, *tmpentry = NULL;
- int i, set = -1, ret = 0;
+ int i, len, set = -1, ret = 0;
if (a->canon_enc) {
free(a->canon_enc);
@@ -456,16 +456,18 @@ x509_name_canon(X509_NAME *a)
}
/* Finally generate encoding */
- a->canon_enclen = i2d_name_canon(intname, NULL);
- p = malloc(a->canon_enclen);
- if (!p)
+ len = i2d_name_canon(intname, NULL);
+ if (len < 0)
+ goto err;
+ p = malloc(len);
+ if (p == NULL)
goto err;
a->canon_enc = p;
+ a->canon_enclen = len;
i2d_name_canon(intname, &p);
ret = 1;
err:
-
if (tmpentry)
X509_NAME_ENTRY_free(tmpentry);
if (intname)