Commit 54105ddd authored by Matt Caswell's avatar Matt Caswell
Browse files

Rename all "read" variables with "readbytes"



Travis is reporting one file at a time shadowed variable warnings where
"read" has been used. This attempts to go through all of libssl and replace
"read" with "readbytes" to fix all the problems in one go.

Reviewed-by: default avatarRich Salz <rsalz@openssl.org>
parent 740bfeba
Loading
Loading
Loading
Loading
+13 −13
Original line number Diff line number Diff line
@@ -184,7 +184,7 @@ const char *SSL_rstate_string(const SSL *s)
 * <0 Failure (may be retryable)
 */
int ssl3_read_n(SSL *s, size_t n, size_t max, int extend, int clearold,
                size_t *read)
                size_t *readbytes)
{
    /*
     * If extend == 0, obtain new n-byte packet; if extend == 1, increase
@@ -270,7 +270,7 @@ int ssl3_read_n(SSL *s, size_t n, size_t max, int extend, int clearold,
        s->rlayer.packet_length += n;
        rb->left = left - n;
        rb->offset += n;
        *read = n;
        *readbytes = n;
        return 1;
    }

@@ -338,7 +338,7 @@ int ssl3_read_n(SSL *s, size_t n, size_t max, int extend, int clearold,
    rb->left = left - n;
    s->rlayer.packet_length += n;
    s->rwstate = SSL_NOTHING;
    *read = n;
    *readbytes = n;
    return 1;
}

@@ -992,10 +992,10 @@ int ssl3_write_pending(SSL *s, int type, const unsigned char *buf, size_t len,
 *             none of our business
 */
int ssl3_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf,
                    size_t len, int peek, size_t *read)
                    size_t len, int peek, size_t *readbytes)
{
    int al, i, j, ret;
    size_t n, curr_rec, num_recs, read_bytes;
    size_t n, curr_rec, num_recs, totalbytes;
    SSL3_RECORD *rr;
    SSL3_BUFFER *rbuf;
    void (*cb) (const SSL *ssl, int type2, int val) = NULL;
@@ -1038,7 +1038,7 @@ int ssl3_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf,
        if (recvd_type != NULL)
            *recvd_type = SSL3_RT_HANDSHAKE;

        *read = n;
        *readbytes = n;
        return 1;
    }

@@ -1156,12 +1156,12 @@ int ssl3_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf,
        if (len == 0)
            return 0;

        read_bytes = 0;
        totalbytes = 0;
        do {
            if (len - read_bytes > SSL3_RECORD_get_length(rr))
            if (len - totalbytes > SSL3_RECORD_get_length(rr))
                n = SSL3_RECORD_get_length(rr);
            else
                n = len - read_bytes;
                n = len - totalbytes;

            memcpy(buf, &(rr->data[rr->off]), n);
            buf += n;
@@ -1183,10 +1183,10 @@ int ssl3_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf,
                curr_rec++;
                rr++;
            }
            read_bytes += n;
            totalbytes += n;
        } while (type == SSL3_RT_APPLICATION_DATA && curr_rec < num_recs
                 && read_bytes < len);
        if (read_bytes == 0) {
                 && totalbytes < len);
        if (totalbytes == 0) {
            /* We must have read empty records. Get more data */
            goto start;
        }
@@ -1194,7 +1194,7 @@ int ssl3_read_bytes(SSL *s, int type, int *recvd_type, unsigned char *buf,
            && (s->mode & SSL_MODE_RELEASE_BUFFERS)
            && SSL3_BUFFER_get_left(rbuf) == 0)
            ssl3_release_read_buffer(s);
        *read = read_bytes;
        *readbytes = totalbytes;
        return 1;
    }

+2 −2
Original line number Diff line number Diff line
@@ -222,7 +222,7 @@ int do_ssl3_write(SSL *s, int type, const unsigned char *buf,
                  int create_empty_fragment, size_t *written);
__owur int ssl3_read_bytes(SSL *s, int type, int *recvd_type,
                           unsigned char *buf, size_t len, int peek,
                           size_t *read);
                           size_t *readbytes);
__owur int ssl3_setup_buffers(SSL *s);
__owur int ssl3_enc(SSL *s, SSL3_RECORD *inrecs, size_t n_recs, int send);
__owur int n_ssl3_mac(SSL *ssl, SSL3_RECORD *rec, unsigned char *md, int send);
@@ -239,7 +239,7 @@ void DTLS_RECORD_LAYER_resync_write(RECORD_LAYER *rl);
void DTLS_RECORD_LAYER_set_write_sequence(RECORD_LAYER *rl, unsigned char *seq);
__owur int dtls1_read_bytes(SSL *s, int type, int *recvd_type,
                            unsigned char *buf, size_t len, int peek,
                            size_t *read);
                            size_t *readbytes);
__owur int dtls1_write_bytes(SSL *s, int type, const void *buf, size_t len,
                             size_t *written);
int do_dtls1_write(SSL *s, int type, const unsigned char *buf,
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@
#define DTLS_RECORD_LAYER_get_r_epoch(rl)       ((rl)->d->r_epoch)

__owur int ssl3_read_n(SSL *s, size_t n, size_t max, int extend, int clearold,
                       size_t *read);
                       size_t *readbytes);

void RECORD_LAYER_set_write_sequence(RECORD_LAYER *rl, const unsigned char *ws);
DTLS1_BITMAP *dtls1_get_bitmap(SSL *s, SSL3_RECORD *rr,
+9 −9
Original line number Diff line number Diff line
@@ -3813,11 +3813,11 @@ int ssl3_shutdown(SSL *s)
            return (ret);
        }
    } else if (!(s->shutdown & SSL_RECEIVED_SHUTDOWN)) {
        size_t read;
        size_t readbytes;
        /*
         * If we are waiting for a close from our peer, we are closed
         */
        s->method->ssl_read_bytes(s, 0, NULL, NULL, 0, 0, &read);
        s->method->ssl_read_bytes(s, 0, NULL, NULL, 0, 0, &readbytes);
        if (!(s->shutdown & SSL_RECEIVED_SHUTDOWN)) {
            return -1;        /* return WANT_READ */
        }
@@ -3841,7 +3841,7 @@ int ssl3_write(SSL *s, const void *buf, size_t len, size_t *written)
}

static int ssl3_read_internal(SSL *s, void *buf, size_t len, int peek,
                              size_t *read)
                              size_t *readbytes)
{
    int ret;

@@ -3851,7 +3851,7 @@ static int ssl3_read_internal(SSL *s, void *buf, size_t len, int peek,
    s->s3->in_read_app_data = 1;
    ret =
        s->method->ssl_read_bytes(s, SSL3_RT_APPLICATION_DATA, NULL, buf, len,
                                  peek, read);
                                  peek, readbytes);
    if ((ret == -1) && (s->s3->in_read_app_data == 2)) {
        /*
         * ssl3_read_bytes decided to call s->handshake_func, which called
@@ -3863,7 +3863,7 @@ static int ssl3_read_internal(SSL *s, void *buf, size_t len, int peek,
        ossl_statem_set_in_handshake(s, 1);
        ret =
            s->method->ssl_read_bytes(s, SSL3_RT_APPLICATION_DATA, NULL, buf,
                                      len, peek, read);
                                      len, peek, readbytes);
        ossl_statem_set_in_handshake(s, 0);
    } else
        s->s3->in_read_app_data = 0;
@@ -3871,14 +3871,14 @@ static int ssl3_read_internal(SSL *s, void *buf, size_t len, int peek,
    return ret;
}

int ssl3_read(SSL *s, void *buf, size_t len, size_t *read)
int ssl3_read(SSL *s, void *buf, size_t len, size_t *readbytes)
{
    return ssl3_read_internal(s, buf, len, 0, read);
    return ssl3_read_internal(s, buf, len, 0, readbytes);
}

int ssl3_peek(SSL *s, void *buf, size_t len, size_t *read)
int ssl3_peek(SSL *s, void *buf, size_t len, size_t *readbytes)
{
    return ssl3_read_internal(s, buf, len, 1, read);
    return ssl3_read_internal(s, buf, len, 1, readbytes);
}

int ssl3_renegotiate(SSL *s)
+12 −12
Original line number Diff line number Diff line
@@ -1533,26 +1533,26 @@ static int ssl_io_intern(void *vargs)
int SSL_read(SSL *s, void *buf, int num)
{
    int ret;
    size_t read;
    size_t readbytes;

    if (num < 0) {
        SSLerr(SSL_F_SSL_READ, SSL_R_BAD_LENGTH);
        return -1;
    }

    ret = SSL_read_ex(s, buf, (size_t)num, &read);
    ret = SSL_read_ex(s, buf, (size_t)num, &readbytes);

    /*
     * The cast is safe here because ret should be <= INT_MAX because num is
     * <= INT_MAX
     */
    if (ret > 0)
        ret = (int)read;
        ret = (int)readbytes;

    return ret;
}

int SSL_read_ex(SSL *s, void *buf, size_t num, size_t *read)
int SSL_read_ex(SSL *s, void *buf, size_t num, size_t *readbytes)
{
    if (s->handshake_func == NULL) {
        SSLerr(SSL_F_SSL_READ_EX, SSL_R_UNINITIALIZED);
@@ -1575,36 +1575,36 @@ int SSL_read_ex(SSL *s, void *buf, size_t num, size_t *read)
        args.f.func_read = s->method->ssl_read;

        ret = ssl_start_async_job(s, &args, ssl_io_intern);
        *read = s->asyncrw;
        *readbytes = s->asyncrw;
        return ret;
    } else {
        return s->method->ssl_read(s, buf, num, read);
        return s->method->ssl_read(s, buf, num, readbytes);
    }
}

int SSL_peek(SSL *s, void *buf, int num)
{
    int ret;
    size_t read;
    size_t readbytes;

    if (num < 0) {
        SSLerr(SSL_F_SSL_PEEK, SSL_R_BAD_LENGTH);
        return -1;
    }

    ret = SSL_peek_ex(s, buf, (size_t)num, &read);
    ret = SSL_peek_ex(s, buf, (size_t)num, &readbytes);

    /*
     * The cast is safe here because ret should be <= INT_MAX because num is
     * <= INT_MAX
     */
    if (ret > 0)
        ret = (int)read;
        ret = (int)readbytes;

    return ret;
}

int SSL_peek_ex(SSL *s, void *buf, size_t num, size_t *read)
int SSL_peek_ex(SSL *s, void *buf, size_t num, size_t *readbytes)
{
    if (s->handshake_func == NULL) {
        SSLerr(SSL_F_SSL_PEEK_EX, SSL_R_UNINITIALIZED);
@@ -1625,10 +1625,10 @@ int SSL_peek_ex(SSL *s, void *buf, size_t num, size_t *read)
        args.f.func_read = s->method->ssl_peek;

        ret = ssl_start_async_job(s, &args, ssl_io_intern);
        *read = s->asyncrw;
        *readbytes = s->asyncrw;
        return ret;
    } else {
        return s->method->ssl_peek(s, buf, num, read);
        return s->method->ssl_peek(s, buf, num, readbytes);
    }
}

Loading