Commit 17dd65e6 authored by Matt Caswell's avatar Matt Caswell
Browse files

Resolve swallowed returns codes



The recent updates to libssl to enforce stricter return code checking, left
a small number of instances behind where return codes were being swallowed
(typically because the function they were being called from was declared as
void). This commit fixes those instances to handle the return codes more
appropriately.

Reviewed-by: default avatarRichard Levitte <levitte@openssl.org>
parent cb14aec7
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -453,7 +453,10 @@ connection defined in the B<SSL> structure.

=item int B<SSL_connect>(SSL *ssl);

=item void B<SSL_copy_session_id>(SSL *t, const SSL *f);
=item int B<SSL_copy_session_id>(SSL *t, const SSL *f);

Sets the session details for B<t> to be the same as in B<f>. Returns 1 on
success or 0 on failure.

=item long B<SSL_ctrl>(SSL *ssl, int cmd, long larg, char *parg);

@@ -756,5 +759,8 @@ The L<ssl(3)|ssl(3)> document appeared in OpenSSL 0.9.2
B<SSLv2_client_method>, B<SSLv2_server_method> and B<SSLv2_method> where removed
in OpenSSL 1.1.0.

The return type of B<SSL_copy_session_id> was changed from void to int in
OpenSSL 1.1.0.

=cut
+2 −1
Original line number Diff line number Diff line
@@ -556,7 +556,8 @@ int BIO_ssl_copy_session_id(BIO *t, BIO *f)
    if ((((BIO_SSL *)t->ptr)->ssl == NULL) ||
        (((BIO_SSL *)f->ptr)->ssl == NULL))
        return (0);
    SSL_copy_session_id(((BIO_SSL *)t->ptr)->ssl, ((BIO_SSL *)f->ptr)->ssl);
    if(!SSL_copy_session_id(((BIO_SSL *)t->ptr)->ssl, ((BIO_SSL *)f->ptr)->ssl))
        return 0;
    return (1);
}

+1 −2
Original line number Diff line number Diff line
@@ -1249,8 +1249,7 @@ int dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek)
            if (dtls1_check_timeout_num(s) < 0)
                return -1;

            /* Ignore retransmit failures - swallow return code */
            if(dtls1_retransmit_buffered_messages(s));
            dtls1_retransmit_buffered_messages(s);
            rr->length = 0;
            goto start;
        }
+1 −1
Original line number Diff line number Diff line
@@ -1467,7 +1467,7 @@ __owur int SSL_SESSION_has_ticket(const SSL_SESSION *s);
__owur unsigned long SSL_SESSION_get_ticket_lifetime_hint(const SSL_SESSION *s);
void SSL_SESSION_get0_ticket(const SSL_SESSION *s, unsigned char **tick,
                            size_t *len);
void SSL_copy_session_id(SSL *to, const SSL *from);
__owur int SSL_copy_session_id(SSL *to, const SSL *from);
__owur X509 *SSL_SESSION_get0_peer(SSL_SESSION *s);
__owur int SSL_SESSION_set1_id_context(SSL_SESSION *s, const unsigned char *sid_ctx,
                                unsigned int sid_ctx_len);
+7 −6
Original line number Diff line number Diff line
@@ -880,12 +880,11 @@ STACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *s)
 * Now in theory, since the calling process own 't' it should be safe to
 * modify.  We need to be able to read f without being hassled
 */
void SSL_copy_session_id(SSL *t, const SSL *f)
int SSL_copy_session_id(SSL *t, const SSL *f)
{
    /* Do we need to to SSL locking? */
    if(!SSL_set_session(t, SSL_get_session(f))) {
        /* How do we handle this!! void function */
        return;
        return 0;
    }

    /*
@@ -901,9 +900,10 @@ void SSL_copy_session_id(SSL *t, const SSL *f)
    ssl_cert_free(t->cert);
    t->cert = f->cert;
    if(!SSL_set_session_id_context(t, f->sid_ctx, f->sid_ctx_length)) {
        /* Really should do something about this..but void function - ignore */
        ;
        return 0;
    }

    return 1;
}

/* Fix this so it checks all the valid key/cert options */
@@ -2757,7 +2757,8 @@ SSL *SSL_dup(SSL *s)

    if (s->session != NULL) {
        /* This copies session-id, SSL_METHOD, sid_ctx, and 'cert' */
        SSL_copy_session_id(ret, s);
        if(!SSL_copy_session_id(ret, s))
            goto err;
    } else {
        /*
         * No session has been established yet, so we have to expect that
Loading