summaryrefslogtreecommitdiffstats
path: root/ssl
diff options
context:
space:
mode:
Diffstat (limited to 'ssl')
-rw-r--r--ssl/record/rec_layer_s3.c26
-rw-r--r--ssl/record/record.h4
-rw-r--r--ssl/record/record_locl.h2
-rw-r--r--ssl/s3_lib.c18
-rw-r--r--ssl/ssl_lib.c24
-rw-r--r--ssl/ssl_locl.h10
-rw-r--r--ssl/statem/statem_dtls.c41
-rw-r--r--ssl/statem/statem_lib.c20
8 files changed, 73 insertions, 72 deletions
diff --git a/ssl/record/rec_layer_s3.c b/ssl/record/rec_layer_s3.c
index 165b032748..a20bc3ef21 100644
--- a/ssl/record/rec_layer_s3.c
+++ b/ssl/record/rec_layer_s3.c
@@ -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;
}
diff --git a/ssl/record/record.h b/ssl/record/record.h
index bd0a0906a1..e30010d170 100644
--- a/ssl/record/record.h
+++ b/ssl/record/record.h
@@ -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,
diff --git a/ssl/record/record_locl.h b/ssl/record/record_locl.h
index c5d5b6485f..6394835404 100644
--- a/ssl/record/record_locl.h
+++ b/ssl/record/record_locl.h
@@ -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,
diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c
index 45824012ef..90c1c66744 100644
--- a/ssl/s3_lib.c
+++ b/ssl/s3_lib.c
@@ -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)
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
index 4e2369d52f..363b4f4ab8 100644
--- a/ssl/ssl_lib.c
+++ b/ssl/ssl_lib.c
@@ -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);
}
}
diff --git a/ssl/ssl_locl.h b/ssl/ssl_locl.h
index b540d890df..0c6bd31993 100644
--- a/ssl/ssl_locl.h
+++ b/ssl/ssl_locl.h
@@ -444,15 +444,15 @@ struct ssl_method_st {
void (*ssl_free) (SSL *s);
int (*ssl_accept) (SSL *s);
int (*ssl_connect) (SSL *s);
- int (*ssl_read) (SSL *s, void *buf, size_t len, size_t *read);
- int (*ssl_peek) (SSL *s, void *buf, size_t len, size_t *read);
+ int (*ssl_read) (SSL *s, void *buf, size_t len, size_t *readbytes);
+ int (*ssl_peek) (SSL *s, void *buf, size_t len, size_t *readbytes);
int (*ssl_write) (SSL *s, const void *buf, size_t len, size_t *written);
int (*ssl_shutdown) (SSL *s);
int (*ssl_renegotiate) (SSL *s);
int (*ssl_renegotiate_check) (SSL *s);
int (*ssl_read_bytes) (SSL *s, int type, int *recvd_type,
unsigned char *buf, size_t len, int peek,
- size_t *read);
+ size_t *readbytes);
int (*ssl_write_bytes) (SSL *s, int type, const void *buf_, size_t len,
size_t *written);
int (*ssl_dispatch_alert) (SSL *s);
@@ -1893,8 +1893,8 @@ __owur const SSL_CIPHER *ssl3_choose_cipher(SSL *ssl,
__owur int ssl3_digest_cached_records(SSL *s, int keep);
__owur int ssl3_new(SSL *s);
void ssl3_free(SSL *s);
-__owur int ssl3_read(SSL *s, void *buf, size_t len, size_t *read);
-__owur int ssl3_peek(SSL *s, void *buf, size_t len, size_t *read);
+__owur int ssl3_read(SSL *s, void *buf, size_t len, size_t *readbytes);
+__owur int ssl3_peek(SSL *s, void *buf, size_t len, size_t *readbytes);
__owur int ssl3_write(SSL *s, const void *buf, size_t len, size_t *written);
__owur int ssl3_shutdown(SSL *s);
void ssl3_clear(SSL *s);
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