Fix memory leak with client auth.
[openssl.git] / ssl / t1_lib.c
index 0626fc6..31fc70e 100644 (file)
@@ -1708,14 +1708,14 @@ unsigned char *ssl_add_serverhello_tlsext(SSL *s, unsigned char *p, unsigned cha
 
                /* NULL callback or -1 omits extension */
                if (!record->fn2)
-                       break;
+                       continue;
                cb_retval = record->fn2(s, record->ext_type,
                                                                &out, &outlen, al,
                                                                record->arg);
                if (cb_retval == 0)
                        return NULL; /* error */
                if (cb_retval == -1)
-                       break; /* skip this extension */
+                       continue; /* skip this extension */
                if (limit < ret + 4 + outlen)
                        return NULL;
                s2n(record->ext_type, ret);
@@ -3644,6 +3644,11 @@ static int tls1_set_shared_sigalgs(SSL *s)
        TLS_SIGALGS *salgs = NULL;
        CERT *c = s->cert;
        unsigned int is_suiteb = tls1_suiteb(s);
+       if (c->shared_sigalgs)
+               {
+               OPENSSL_free(c->shared_sigalgs);
+               c->shared_sigalgs = NULL;
+               }
        /* If client use client signature algorithms if not NULL */
        if (!s->server && c->client_sigalgs && !is_suiteb)
                {
@@ -3700,6 +3705,8 @@ int tls1_process_sigalgs(SSL *s, const unsigned char *data, int dsize)
        if (!c)
                return 0;
 
+       if (c->peer_sigalgs)
+               OPENSSL_free(c->peer_sigalgs);
        c->peer_sigalgs = OPENSSL_malloc(dsize);
        if (!c->peer_sigalgs)
                return 0;