[openssl-commits] [openssl] OpenSSL_1_0_2-stable update
Matt Caswell
matt at openssl.org
Wed Feb 21 12:32:33 UTC 2018
The branch OpenSSL_1_0_2-stable has been updated
via a25e2d49a75eb01dcdad41a5bec05666d461b2d6 (commit)
via becdc13fd87052058c87dd0ee3894345617085b8 (commit)
from cb7503750efc02c64cdb7167dee692e47c44c6e9 (commit)
- Log -----------------------------------------------------------------
commit a25e2d49a75eb01dcdad41a5bec05666d461b2d6
Author: Pavel Kopyl <p.kopyl at samsung.com>
Date: Sun Dec 10 22:57:43 2017 +0300
do_body: fix heap-use-after-free.
The memory pointed to by the 'push' is freed by the
X509_NAME_ENTRY_free() in do_body(). The second time
it is referenced to (indirectly) in certify_cert:X509_REQ_free().
Reviewed-by: Bernd Edlinger <bernd.edlinger at hotmail.de>
Reviewed-by: Matt Caswell <matt at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4896)
commit becdc13fd87052058c87dd0ee3894345617085b8
Author: Pavel Kopyl <p.kopyl at samsung.com>
Date: Sun Dec 10 22:49:42 2017 +0300
X509V3_EXT_add_nconf_sk, X509v3_add_ext: fix errors handling
X509v3_add_ext: free 'sk' if the memory pointed to by it
was malloc-ed inside this function.
X509V3_EXT_add_nconf_sk: return an error if X509v3_add_ext() fails.
This prevents use of a freed memory in do_body:sk_X509_EXTENSION_num().
Reviewed-by: Bernd Edlinger <bernd.edlinger at hotmail.de>
Reviewed-by: Matt Caswell <matt at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4896)
-----------------------------------------------------------------------
Summary of changes:
apps/ca.c | 2 --
crypto/x509/x509_v3.c | 2 +-
crypto/x509v3/v3_conf.c | 8 ++++++--
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/apps/ca.c b/apps/ca.c
index bde3e44..06002ad 100644
--- a/apps/ca.c
+++ b/apps/ca.c
@@ -1825,8 +1825,6 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
if (push != NULL) {
if (!X509_NAME_add_entry(subject, push, -1, 0)) {
- if (push != NULL)
- X509_NAME_ENTRY_free(push);
BIO_printf(bio_err, "Memory allocation failure\n");
goto err;
}
diff --git a/crypto/x509/x509_v3.c b/crypto/x509/x509_v3.c
index 4a03445..9a3517e 100644
--- a/crypto/x509/x509_v3.c
+++ b/crypto/x509/x509_v3.c
@@ -177,7 +177,7 @@ STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x,
err2:
if (new_ex != NULL)
X509_EXTENSION_free(new_ex);
- if (sk != NULL)
+ if (x != NULL && *x == NULL && sk != NULL)
sk_X509_EXTENSION_free(sk);
return (NULL);
}
diff --git a/crypto/x509v3/v3_conf.c b/crypto/x509v3/v3_conf.c
index c1b4c1a..c984aa0 100644
--- a/crypto/x509v3/v3_conf.c
+++ b/crypto/x509v3/v3_conf.c
@@ -340,8 +340,12 @@ int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, char *section,
val = sk_CONF_VALUE_value(nval, i);
if (!(ext = X509V3_EXT_nconf(conf, ctx, val->name, val->value)))
return 0;
- if (sk)
- X509v3_add_ext(sk, ext, -1);
+ if (sk != NULL) {
+ if (X509v3_add_ext(sk, ext, -1) == NULL) {
+ X509_EXTENSION_free(ext);
+ return 0;
+ }
+ }
X509_EXTENSION_free(ext);
}
return 1;
More information about the openssl-commits
mailing list