diff options
Diffstat (limited to 'src/lib/libssl/s3_pkt.c')
| -rw-r--r-- | src/lib/libssl/s3_pkt.c | 24 | 
1 files changed, 15 insertions, 9 deletions
| diff --git a/src/lib/libssl/s3_pkt.c b/src/lib/libssl/s3_pkt.c index 1414079853..9ab76604a6 100644 --- a/src/lib/libssl/s3_pkt.c +++ b/src/lib/libssl/s3_pkt.c | |||
| @@ -704,7 +704,7 @@ static int ssl3_write_pending(SSL *s, int type, const unsigned char *buf, | |||
| 704 | * Application data protocol | 704 | * Application data protocol | 
| 705 | * none of our business | 705 | * none of our business | 
| 706 | */ | 706 | */ | 
| 707 | int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len) | 707 | int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) | 
| 708 | { | 708 | { | 
| 709 | int al,i,j,ret; | 709 | int al,i,j,ret; | 
| 710 | unsigned int n; | 710 | unsigned int n; | 
| @@ -715,7 +715,8 @@ int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len) | |||
| 715 | if (!ssl3_setup_buffers(s)) | 715 | if (!ssl3_setup_buffers(s)) | 
| 716 | return(-1); | 716 | return(-1); | 
| 717 | 717 | ||
| 718 | if ((type != SSL3_RT_APPLICATION_DATA) && (type != SSL3_RT_HANDSHAKE) && type) | 718 | if ((type && (type != SSL3_RT_APPLICATION_DATA) && (type != SSL3_RT_HANDSHAKE) && type) || | 
| 719 | (peek && (type != SSL3_RT_APPLICATION_DATA))) | ||
| 719 | { | 720 | { | 
| 720 | SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_INTERNAL_ERROR); | 721 | SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_INTERNAL_ERROR); | 
| 721 | return -1; | 722 | return -1; | 
| @@ -728,6 +729,7 @@ int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len) | |||
| 728 | unsigned char *dst = buf; | 729 | unsigned char *dst = buf; | 
| 729 | unsigned int k; | 730 | unsigned int k; | 
| 730 | 731 | ||
| 732 | /* peek == 0 */ | ||
| 731 | n = 0; | 733 | n = 0; | 
| 732 | while ((len > 0) && (s->s3->handshake_fragment_len > 0)) | 734 | while ((len > 0) && (s->s3->handshake_fragment_len > 0)) | 
| 733 | { | 735 | { | 
| @@ -763,7 +765,7 @@ start: | |||
| 763 | * s->s3->rrec.length, - number of bytes. */ | 765 | * s->s3->rrec.length, - number of bytes. */ | 
| 764 | rr = &(s->s3->rrec); | 766 | rr = &(s->s3->rrec); | 
| 765 | 767 | ||
| 766 | /* get new packet */ | 768 | /* get new packet if necessary */ | 
| 767 | if ((rr->length == 0) || (s->rstate == SSL_ST_READ_BODY)) | 769 | if ((rr->length == 0) || (s->rstate == SSL_ST_READ_BODY)) | 
| 768 | { | 770 | { | 
| 769 | ret=ssl3_get_record(s); | 771 | ret=ssl3_get_record(s); | 
| @@ -781,7 +783,8 @@ start: | |||
| 781 | goto err; | 783 | goto err; | 
| 782 | } | 784 | } | 
| 783 | 785 | ||
| 784 | /* If the other end has shutdown, throw anything we read away */ | 786 | /* If the other end has shut down, throw anything we read away | 
| 787 | * (even in 'peek' mode) */ | ||
| 785 | if (s->shutdown & SSL_RECEIVED_SHUTDOWN) | 788 | if (s->shutdown & SSL_RECEIVED_SHUTDOWN) | 
| 786 | { | 789 | { | 
| 787 | rr->length=0; | 790 | rr->length=0; | 
| @@ -810,12 +813,15 @@ start: | |||
| 810 | n = (unsigned int)len; | 813 | n = (unsigned int)len; | 
| 811 | 814 | ||
| 812 | memcpy(buf,&(rr->data[rr->off]),n); | 815 | memcpy(buf,&(rr->data[rr->off]),n); | 
| 813 | rr->length-=n; | 816 | if (!peek) | 
| 814 | rr->off+=n; | ||
| 815 | if (rr->length == 0) | ||
| 816 | { | 817 | { | 
| 817 | s->rstate=SSL_ST_READ_HEADER; | 818 | rr->length-=n; | 
| 818 | rr->off=0; | 819 | rr->off+=n; | 
| 820 | if (rr->length == 0) | ||
| 821 | { | ||
| 822 | s->rstate=SSL_ST_READ_HEADER; | ||
| 823 | rr->off=0; | ||
| 824 | } | ||
| 819 | } | 825 | } | 
| 820 | return(n); | 826 | return(n); | 
| 821 | } | 827 | } | 
