diff options
author | Matt Caswell <matt@openssl.org> | 2015-02-02 13:43:38 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2015-03-26 15:01:59 +0000 |
commit | bbcd6d7fe263361f18060c40cac676d6a6193ead (patch) | |
tree | 75f7c18344ebb9d7ffec1cf7804fbe01b444222d | |
parent | f161995e0e1a77415354b1690fb92ae3f1480547 (diff) |
Provide RECORD_LAYER_set_data function
Reviewed-by: Richard Levitte <levitte@openssl.org>
-rw-r--r-- | ssl/record/rec_layer.h | 1 | ||||
-rw-r--r-- | ssl/record/s3_pkt.c | 16 | ||||
-rw-r--r-- | ssl/record/ssl3_buffer.c | 2 | ||||
-rw-r--r-- | ssl/record/ssl3_buffer.h | 2 | ||||
-rw-r--r-- | ssl/s23_clnt.c | 9 | ||||
-rw-r--r-- | ssl/s23_srvr.c | 14 |
6 files changed, 25 insertions, 19 deletions
diff --git a/ssl/record/rec_layer.h b/ssl/record/rec_layer.h index 96e245e2c0..4d91476d4e 100644 --- a/ssl/record/rec_layer.h +++ b/ssl/record/rec_layer.h @@ -170,6 +170,7 @@ void RECORD_LAYER_clear(RECORD_LAYER *rl); void RECORD_LAYER_release(RECORD_LAYER *rl); int RECORD_LAYER_read_pending(RECORD_LAYER *rl); int RECORD_LAYER_write_pending(RECORD_LAYER *rl); +int RECORD_LAYER_set_data(RECORD_LAYER *rl, const unsigned char *buf, int len); __owur int ssl23_read_bytes(SSL *s, int n); __owur int ssl23_write_bytes(SSL *s); __owur int ssl3_write_bytes(SSL *s, int type, const void *buf, int len); diff --git a/ssl/record/s3_pkt.c b/ssl/record/s3_pkt.c index 21ded63e38..376697f744 100644 --- a/ssl/record/s3_pkt.c +++ b/ssl/record/s3_pkt.c @@ -178,6 +178,22 @@ int RECORD_LAYER_write_pending(RECORD_LAYER *rl) return SSL3_BUFFER_get_left(&rl->wbuf) != 0; } +int RECORD_LAYER_set_data(RECORD_LAYER *rl, const unsigned char *buf, int len) +{ + rl->s->packet_length = len; + if(len != 0) { + rl->s->rstate = SSL_ST_READ_HEADER; + if (!SSL3_BUFFER_is_initialised(&rl->rbuf)) + if (!ssl3_setup_read_buffer(rl->s)) + return 0; + } + + rl->s->packet = SSL3_BUFFER_get_buf(&rl->rbuf); + SSL3_BUFFER_set_data(&rl->rbuf, buf, len); + + return 1; +} + int ssl3_read_n(SSL *s, int n, int max, int extend) { /* diff --git a/ssl/record/ssl3_buffer.c b/ssl/record/ssl3_buffer.c index 65dcd8a292..2ea55c8ba4 100644 --- a/ssl/record/ssl3_buffer.c +++ b/ssl/record/ssl3_buffer.c @@ -111,7 +111,7 @@ #include "../ssl_locl.h" -void SSL3_BUFFER_set_data(SSL3_BUFFER *b, unsigned char *d, int n) +void SSL3_BUFFER_set_data(SSL3_BUFFER *b, const unsigned char *d, int n) { if(d != NULL) memcpy(b->buf, d, n); diff --git a/ssl/record/ssl3_buffer.h b/ssl/record/ssl3_buffer.h index 4668f4507a..8e55250a25 100644 --- a/ssl/record/ssl3_buffer.h +++ b/ssl/record/ssl3_buffer.h @@ -127,7 +127,7 @@ typedef struct ssl3_buffer_st { #define SSL3_BUFFER_get_left(b) ((b)->left) #define SSL3_BUFFER_is_initialised(b) ((b)->buf != NULL) -void SSL3_BUFFER_set_data(SSL3_BUFFER *b, unsigned char *d, int n); +void SSL3_BUFFER_set_data(SSL3_BUFFER *b, const unsigned char *d, int n); void SSL3_BUFFER_release(SSL3_BUFFER *b); __owur int ssl3_setup_buffers(SSL *s); __owur int ssl3_setup_read_buffer(SSL *s); diff --git a/ssl/s23_clnt.c b/ssl/s23_clnt.c index abefcaa0ef..0bc5946666 100644 --- a/ssl/s23_clnt.c +++ b/ssl/s23_clnt.c @@ -573,13 +573,8 @@ static int ssl23_get_server_hello(SSL *s) /* * put the 7 bytes we have read into the input buffer for SSLv3 */ - s->rstate = SSL_ST_READ_HEADER; - s->packet_length = n; - if (!SSL3_BUFFER_is_initialised(RECORD_LAYER_get_rbuf(&s->rlayer))) - if (!ssl3_setup_read_buffer(s)) - goto err; - s->packet = SSL3_BUFFER_get_buf(RECORD_LAYER_get_rbuf(&s->rlayer)); - SSL3_BUFFER_set_data(RECORD_LAYER_get_rbuf(&s->rlayer), buf, n); + if(!RECORD_LAYER_set_data(&s->rlayer, buf, n)) + goto err; s->handshake_func = s->method->ssl_connect; } else { diff --git a/ssl/s23_srvr.c b/ssl/s23_srvr.c index 349d66b474..3ff0ef642e 100644 --- a/ssl/s23_srvr.c +++ b/ssl/s23_srvr.c @@ -556,17 +556,11 @@ int ssl23_get_client_hello(SSL *s) /* * put the 'n' bytes we have read into the input buffer for SSLv3 */ - s->rstate = SSL_ST_READ_HEADER; - s->packet_length = n; - if (!SSL3_BUFFER_is_initialised(RECORD_LAYER_get_rbuf(&s->rlayer))) - if (!ssl3_setup_read_buffer(s)) - goto err; - - s->packet = SSL3_BUFFER_get_buf(RECORD_LAYER_get_rbuf(&s->rlayer)); - SSL3_BUFFER_set_data(RECORD_LAYER_get_rbuf(&s->rlayer), buf, n); + if(!RECORD_LAYER_set_data(&s->rlayer, buf, n)) + goto err; } else { - s->packet_length = 0; - SSL3_BUFFER_set_data(RECORD_LAYER_get_rbuf(&s->rlayer), NULL, 0); + if(!RECORD_LAYER_set_data(&s->rlayer, NULL, 0)) + goto err; } s->handshake_func = s->method->ssl_accept; } else { |