From 70ee3cb33663d3f5f9666994a129f8053d8ef7b5 Mon Sep 17 00:00:00 2001 From: jkim Date: Thu, 2 Nov 2017 18:22:53 +0000 Subject: MFC: r318899 Merge OpenSSL 1.0.2l. (cherry picked from commit ffd1bb8c599181e0733f8e00d8d8198b4ea6a73b) --- crypto/openssl/ssl/t1_ext.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'crypto/openssl/ssl/t1_ext.c') diff --git a/crypto/openssl/ssl/t1_ext.c b/crypto/openssl/ssl/t1_ext.c index 79ed946..0f4aba0 100644 --- a/crypto/openssl/ssl/t1_ext.c +++ b/crypto/openssl/ssl/t1_ext.c @@ -179,6 +179,25 @@ int custom_ext_add(SSL *s, int server, return 1; } +/* Copy the flags from src to dst for any extensions that exist in both */ +int custom_exts_copy_flags(custom_ext_methods *dst, + const custom_ext_methods *src) +{ + size_t i; + custom_ext_method *methsrc = src->meths; + + for (i = 0; i < src->meths_count; i++, methsrc++) { + custom_ext_method *methdst = custom_ext_find(dst, methsrc->ext_type); + + if (methdst == NULL) + continue; + + methdst->ext_flags = methsrc->ext_flags; + } + + return 1; +} + /* Copy table of custom extensions */ int custom_exts_copy(custom_ext_methods *dst, const custom_ext_methods *src) { @@ -223,16 +242,14 @@ static int custom_ext_meth_add(custom_ext_methods *exts, /* Search for duplicate */ if (custom_ext_find(exts, ext_type)) return 0; - exts->meths = OPENSSL_realloc(exts->meths, - (exts->meths_count + - 1) * sizeof(custom_ext_method)); - - if (!exts->meths) { - exts->meths_count = 0; + meth = OPENSSL_realloc(exts->meths, + (exts->meths_count + 1) + * sizeof(custom_ext_method)); + if (meth == NULL) return 0; - } - meth = exts->meths + exts->meths_count; + exts->meths = meth; + meth += exts->meths_count; memset(meth, 0, sizeof(custom_ext_method)); meth->parse_cb = parse_cb; meth->add_cb = add_cb; -- cgit v1.1