diff options
Diffstat (limited to 'src/lib/libssl/ssl_pkt.c')
| -rw-r--r-- | src/lib/libssl/ssl_pkt.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/src/lib/libssl/ssl_pkt.c b/src/lib/libssl/ssl_pkt.c index ef5b5737aa..6d1a8481ee 100644 --- a/src/lib/libssl/ssl_pkt.c +++ b/src/lib/libssl/ssl_pkt.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ssl_pkt.c,v 1.2 2017/01/26 06:32:58 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_pkt.c,v 1.3 2017/01/26 06:39:08 beck Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -130,6 +130,22 @@ static int ssl3_get_record(SSL *s); | |||
| 130 | * (If s->internal->read_ahead is set, 'max' bytes may be stored in rbuf | 130 | * (If s->internal->read_ahead is set, 'max' bytes may be stored in rbuf |
| 131 | * [plus s->internal->packet_length bytes if extend == 1].) | 131 | * [plus s->internal->packet_length bytes if extend == 1].) |
| 132 | */ | 132 | */ |
| 133 | |||
| 134 | /* | ||
| 135 | * Force a WANT_READ return for certain error conditions where | ||
| 136 | * we don't want to spin internally. | ||
| 137 | */ | ||
| 138 | static void | ||
| 139 | ssl_force_want_read(SSL *s) | ||
| 140 | { | ||
| 141 | BIO * bio; | ||
| 142 | |||
| 143 | bio = SSL_get_rbio(s); | ||
| 144 | BIO_clear_retry_flags(bio); | ||
| 145 | BIO_set_retry_read(bio); | ||
| 146 | s->internal->rwstate = SSL_READING; | ||
| 147 | } | ||
| 148 | |||
| 133 | static int | 149 | static int |
| 134 | ssl3_read_n(SSL *s, int n, int max, int extend) | 150 | ssl3_read_n(SSL *s, int n, int max, int extend) |
| 135 | { | 151 | { |
| @@ -880,7 +896,6 @@ ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) | |||
| 880 | int al, i, j, ret, rrcount = 0; | 896 | int al, i, j, ret, rrcount = 0; |
| 881 | unsigned int n; | 897 | unsigned int n; |
| 882 | SSL3_RECORD *rr; | 898 | SSL3_RECORD *rr; |
| 883 | BIO *bio; | ||
| 884 | 899 | ||
| 885 | if (s->s3->rbuf.buf == NULL) /* Not initialized yet */ | 900 | if (s->s3->rbuf.buf == NULL) /* Not initialized yet */ |
| 886 | if (!ssl3_setup_read_buffer(s)) | 901 | if (!ssl3_setup_read_buffer(s)) |
| @@ -945,13 +960,7 @@ start: | |||
| 945 | * limited... | 960 | * limited... |
| 946 | */ | 961 | */ |
| 947 | if (rrcount++ >= 3) { | 962 | if (rrcount++ >= 3) { |
| 948 | if ((bio = SSL_get_rbio(s)) == NULL) { | 963 | ssl_force_want_read(s); |
| 949 | SSLerr(SSL_F_SSL3_READ_BYTES, ERR_R_INTERNAL_ERROR); | ||
| 950 | return -1; | ||
| 951 | } | ||
| 952 | BIO_clear_retry_flags(bio); | ||
| 953 | BIO_set_retry_read(bio); | ||
| 954 | s->internal->rwstate = SSL_READING; | ||
| 955 | return -1; | 964 | return -1; |
| 956 | } | 965 | } |
| 957 | 966 | ||
| @@ -1112,10 +1121,7 @@ start: | |||
| 1112 | * but we trigger an SSL handshake, we return -1 with | 1121 | * but we trigger an SSL handshake, we return -1 with |
| 1113 | * the retry option set. Otherwise renegotiation may | 1122 | * the retry option set. Otherwise renegotiation may |
| 1114 | * cause nasty problems in the blocking world */ | 1123 | * cause nasty problems in the blocking world */ |
| 1115 | s->internal->rwstate = SSL_READING; | 1124 | ssl_force_want_read(s); |
| 1116 | bio = SSL_get_rbio(s); | ||
| 1117 | BIO_clear_retry_flags(bio); | ||
| 1118 | BIO_set_retry_read(bio); | ||
| 1119 | return (-1); | 1125 | return (-1); |
| 1120 | } | 1126 | } |
| 1121 | } | 1127 | } |
| @@ -1269,15 +1275,11 @@ start: | |||
| 1269 | 1275 | ||
| 1270 | if (!(s->internal->mode & SSL_MODE_AUTO_RETRY)) { | 1276 | if (!(s->internal->mode & SSL_MODE_AUTO_RETRY)) { |
| 1271 | if (s->s3->rbuf.left == 0) { /* no read-ahead left? */ | 1277 | if (s->s3->rbuf.left == 0) { /* no read-ahead left? */ |
| 1272 | BIO *bio; | ||
| 1273 | /* In the case where we try to read application data, | 1278 | /* In the case where we try to read application data, |
| 1274 | * but we trigger an SSL handshake, we return -1 with | 1279 | * but we trigger an SSL handshake, we return -1 with |
| 1275 | * the retry option set. Otherwise renegotiation may | 1280 | * the retry option set. Otherwise renegotiation may |
| 1276 | * cause nasty problems in the blocking world */ | 1281 | * cause nasty problems in the blocking world */ |
| 1277 | s->internal->rwstate = SSL_READING; | 1282 | ssl_force_want_read(s); |
| 1278 | bio = SSL_get_rbio(s); | ||
| 1279 | BIO_clear_retry_flags(bio); | ||
| 1280 | BIO_set_retry_read(bio); | ||
| 1281 | return (-1); | 1283 | return (-1); |
| 1282 | } | 1284 | } |
| 1283 | } | 1285 | } |
