diff options
author | Matt Caswell <matt@openssl.org> | 2016-10-26 11:43:34 +0200 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-11-04 13:09:46 +0100 |
commit | 54105ddd230c0d77fab91dd3f423b58b2a976de7 (patch) | |
tree | d322b8427a0446f63eea2560ec4a4884666fac90 /ssl/statem | |
parent | Clarify the return values for SSL_read_ex()/SSL_write_ex() (diff) | |
download | openssl-54105ddd230c0d77fab91dd3f423b58b2a976de7.tar.xz openssl-54105ddd230c0d77fab91dd3f423b58b2a976de7.zip |
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: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'ssl/statem')
-rw-r--r-- | ssl/statem/statem_dtls.c | 41 | ||||
-rw-r--r-- | ssl/statem/statem_lib.c | 20 |
2 files changed, 31 insertions, 30 deletions
diff --git a/ssl/statem/statem_dtls.c b/ssl/statem/statem_dtls.c index d2b5f877dc..52e62a4273 100644 --- a/ssl/statem/statem_dtls.c +++ b/ssl/statem/statem_dtls.c @@ -510,7 +510,7 @@ dtls1_reassemble_fragment(SSL *s, const struct hm_header_st *msg_hdr) int i = -1, is_complete; unsigned char seq64be[8]; size_t frag_len = msg_hdr->frag_len; - size_t read; + size_t readbytes; if ((msg_hdr->frag_off + frag_len) > msg_hdr->msg_len || msg_hdr->msg_len > dtls1_max_handshake_message_len(s)) @@ -555,10 +555,10 @@ dtls1_reassemble_fragment(SSL *s, const struct hm_header_st *msg_hdr) devnull, frag_len > sizeof(devnull) ? sizeof(devnull) : - frag_len, 0, &read); + frag_len, 0, &readbytes); if (i <= 0) goto err; - frag_len -= read; + frag_len -= readbytes; } return DTLS1_HM_FRAGMENT_RETRY; } @@ -566,8 +566,8 @@ dtls1_reassemble_fragment(SSL *s, const struct hm_header_st *msg_hdr) /* read the body of the fragment (header has already been read */ i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, NULL, frag->fragment + msg_hdr->frag_off, - frag_len, 0, &read); - if (i <= 0 || read != frag_len) + frag_len, 0, &readbytes); + if (i <= 0 || readbytes != frag_len) i = -1; if (i <= 0) goto err; @@ -616,7 +616,7 @@ dtls1_process_out_of_seq_message(SSL *s, const struct hm_header_st *msg_hdr) pitem *item = NULL; unsigned char seq64be[8]; size_t frag_len = msg_hdr->frag_len; - size_t read; + size_t readbytes; if ((msg_hdr->frag_off + frag_len) > msg_hdr->msg_len) goto err; @@ -649,10 +649,10 @@ dtls1_process_out_of_seq_message(SSL *s, const struct hm_header_st *msg_hdr) devnull, frag_len > sizeof(devnull) ? sizeof(devnull) : - frag_len, 0, &read); + frag_len, 0, &readbytes); if (i <= 0) goto err; - frag_len -= read; + frag_len -= readbytes; } } else { if (frag_len != msg_hdr->msg_len) { @@ -673,8 +673,9 @@ dtls1_process_out_of_seq_message(SSL *s, const struct hm_header_st *msg_hdr) * read the body of the fragment (header has already been read */ i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, NULL, - frag->fragment, frag_len, 0, &read); - if (i<=0 || read != frag_len) + frag->fragment, frag_len, 0, + &readbytes); + if (i<=0 || readbytes != frag_len) i = -1; if (i <= 0) goto err; @@ -710,7 +711,7 @@ static int dtls_get_reassembled_message(SSL *s, int *errtype, size_t *len) size_t mlen, frag_off, frag_len; int i, al, recvd_type; struct hm_header_st msg_hdr; - size_t read; + size_t readbytes; *errtype = 0; @@ -724,7 +725,7 @@ static int dtls_get_reassembled_message(SSL *s, int *errtype, size_t *len) /* read handshake message header */ i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, &recvd_type, wire, - DTLS1_HM_HEADER_LENGTH, 0, &read); + DTLS1_HM_HEADER_LENGTH, 0, &readbytes); if (i <= 0) { /* nbio, or an error */ s->rwstate = SSL_READING; *len = 0; @@ -738,17 +739,17 @@ static int dtls_get_reassembled_message(SSL *s, int *errtype, size_t *len) goto f_err; } - memcpy(s->init_buf->data, wire, read); - s->init_num = read - 1; + memcpy(s->init_buf->data, wire, readbytes); + s->init_num = readbytes - 1; s->init_msg = s->init_buf->data + 1; s->s3->tmp.message_type = SSL3_MT_CHANGE_CIPHER_SPEC; - s->s3->tmp.message_size = read - 1; - *len = read - 1; + s->s3->tmp.message_size = readbytes - 1; + *len = readbytes - 1; return 1; } /* Handshake fails if message header is incomplete */ - if (read != DTLS1_HM_HEADER_LENGTH) { + if (readbytes != DTLS1_HM_HEADER_LENGTH) { al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_DTLS_GET_REASSEMBLED_MESSAGE, SSL_R_UNEXPECTED_MESSAGE); goto f_err; @@ -819,7 +820,7 @@ static int dtls_get_reassembled_message(SSL *s, int *errtype, size_t *len) (unsigned char *)s->init_buf->data + DTLS1_HM_HEADER_LENGTH; i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, NULL, - &p[frag_off], frag_len, 0, &read); + &p[frag_off], frag_len, 0, &readbytes); /* * This shouldn't ever fail due to NBIO because we already checked @@ -831,14 +832,14 @@ static int dtls_get_reassembled_message(SSL *s, int *errtype, size_t *len) return 0; } } else { - read = 0; + readbytes = 0; } /* * XDTLS: an incorrectly formatted fragment should cause the handshake * to fail */ - if (read != frag_len) { + if (readbytes != frag_len) { al = SSL3_AD_ILLEGAL_PARAMETER; SSLerr(SSL_F_DTLS_GET_REASSEMBLED_MESSAGE, SSL3_AD_ILLEGAL_PARAMETER); goto f_err; diff --git a/ssl/statem/statem_lib.c b/ssl/statem/statem_lib.c index 1ce14ee640..990510a06b 100644 --- a/ssl/statem/statem_lib.c +++ b/ssl/statem/statem_lib.c @@ -364,7 +364,7 @@ int tls_get_message_header(SSL *s, int *mt) /* s->init_num < SSL3_HM_HEADER_LENGTH */ int skip_message, i, recvd_type, al; unsigned char *p; - size_t l, read; + size_t l, readbytes; p = (unsigned char *)s->init_buf->data; @@ -373,7 +373,7 @@ int tls_get_message_header(SSL *s, int *mt) i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, &recvd_type, &p[s->init_num], SSL3_HM_HEADER_LENGTH - s->init_num, - 0, &read); + 0, &readbytes); if (i <= 0) { s->rwstate = SSL_READING; return 0; @@ -383,22 +383,22 @@ int tls_get_message_header(SSL *s, int *mt) * A ChangeCipherSpec must be a single byte and may not occur * in the middle of a handshake message. */ - if (s->init_num != 0 || read != 1 || p[0] != SSL3_MT_CCS) { + if (s->init_num != 0 || readbytes != 1 || p[0] != SSL3_MT_CCS) { al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_TLS_GET_MESSAGE_HEADER, SSL_R_BAD_CHANGE_CIPHER_SPEC); goto f_err; } s->s3->tmp.message_type = *mt = SSL3_MT_CHANGE_CIPHER_SPEC; - s->init_num = read - 1; - s->s3->tmp.message_size = read; + s->init_num = readbytes - 1; + s->s3->tmp.message_size = readbytes; return 1; } else if (recvd_type != SSL3_RT_HANDSHAKE) { al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_TLS_GET_MESSAGE_HEADER, SSL_R_CCS_RECEIVED_EARLY); goto f_err; } - s->init_num += read; + s->init_num += readbytes; } skip_message = 0; @@ -461,7 +461,7 @@ int tls_get_message_header(SSL *s, int *mt) int tls_get_message_body(SSL *s, size_t *len) { - size_t n, read; + size_t n, readbytes; unsigned char *p; int i; @@ -475,14 +475,14 @@ int tls_get_message_body(SSL *s, size_t *len) n = s->s3->tmp.message_size - s->init_num; while (n > 0) { i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, NULL, - &p[s->init_num], n, 0, &read); + &p[s->init_num], n, 0, &readbytes); if (i <= 0) { s->rwstate = SSL_READING; *len = 0; return 0; } - s->init_num += read; - n -= read; + s->init_num += readbytes; + n -= readbytes; } #ifndef OPENSSL_NO_NEXTPROTONEG |