Commit 69f68237 authored by Matt Caswell's avatar Matt Caswell
Browse files

Fix missing return value checks



Ensure that all functions have their return values checked where
appropriate. This covers all functions defined and called from within
libssl.

Reviewed-by: default avatarRichard Levitte <levitte@openssl.org>
parent 4bcdb4a6
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -292,7 +292,10 @@ static long ssl_ctrl(BIO *b, int cmd, long num, void *ptr)
        else if (ssl->handshake_func == ssl->method->ssl_accept)
            SSL_set_accept_state(ssl);

        SSL_clear(ssl);
        if(!SSL_clear(ssl)) {
            ret = 0;
            break;
        }

        if (b->next_bio != NULL)
            ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
+5 −4
Original line number Diff line number Diff line
@@ -989,7 +989,10 @@ int dtls1_send_change_cipher_spec(SSL *s, int a, int b)
                                     s->d1->handshake_write_seq, 0, 0);

        /* buffer the message to handle re-xmits */
        dtls1_buffer_message(s, 1);
        if(!dtls1_buffer_message(s, 1)) {
            SSLerr(SSL_F_DTLS1_SEND_CHANGE_CIPHER_SPEC, ERR_R_INTERNAL_ERROR);
            return -1;
        }

        s->state = b;
    }
@@ -1237,7 +1240,7 @@ void dtls1_clear_record_buffer(SSL *s)
    }
}

unsigned char *dtls1_set_message_header(SSL *s, unsigned char *p,
void dtls1_set_message_header(SSL *s, unsigned char *p,
                                        unsigned char mt, unsigned long len,
                                        unsigned long frag_off,
                                        unsigned long frag_len)
@@ -1250,8 +1253,6 @@ unsigned char *dtls1_set_message_header(SSL *s, unsigned char *p,

    dtls1_set_message_header_int(s, mt, len, s->d1->handshake_write_seq,
                                 frag_off, frag_len);

    return p += DTLS1_HM_HEADER_LENGTH;
}

/* don't actually do the writing, wait till the MTU has been retrieved */
+4 −2
Original line number Diff line number Diff line
@@ -181,8 +181,10 @@ int dtls1_connect(SSL *s)
        cb = s->ctx->info_callback;

    s->in_handshake++;
    if (!SSL_in_init(s) || SSL_in_before(s))
        SSL_clear(s);
    if (!SSL_in_init(s) || SSL_in_before(s)) {
        if(!SSL_clear(s))
            return -1;
    }

#ifndef OPENSSL_NO_SCTP
    /*
+5 −1
Original line number Diff line number Diff line
@@ -567,7 +567,11 @@ static void dtls1_set_handshake_header(SSL *s, int htype, unsigned long len)
    s->init_num = (int)len + DTLS1_HM_HEADER_LENGTH;
    s->init_off = 0;
    /* Buffer the message to handle re-xmits */
    dtls1_buffer_message(s, 0);
    /*
     * Deliberately swallow error return. We really should do something with
     * this - but its a void function that can't (easily) be changed
     */
    if(!dtls1_buffer_message(s, 0));
}

static int dtls1_handshake_write(SSL *s)
+6 −2
Original line number Diff line number Diff line
@@ -937,7 +937,10 @@ int dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek)
        }
#ifndef OPENSSL_NO_HEARTBEATS
        else if (rr->type == TLS1_RT_HEARTBEAT) {
            dtls1_process_heartbeat(s);
            /* We allow a 0 return */
            if(dtls1_process_heartbeat(s) < 0) {
                return -1;
            }

            /* Exit and notify application to read again */
            rr->length = 0;
@@ -1246,7 +1249,8 @@ int dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek)
            if (dtls1_check_timeout_num(s) < 0)
                return -1;

            dtls1_retransmit_buffered_messages(s);
            /* Ignore retransmit failures - swallow return code */
            if(dtls1_retransmit_buffered_messages(s));
            rr->length = 0;
            goto start;
        }
Loading