+83
-74
lines changedFilter options
+83
-74
lines changed Original file line number Diff line number Diff line change
@@ -38,12 +38,12 @@ if and only if B<ret E<gt> 0>.
38
38
39
39
=item SSL_ERROR_ZERO_RETURN
40
40
41
-
The TLS/SSL connection has been closed. If the protocol version is SSL 3.0
42
-
or TLS 1.0, this result code is returned only if a closure
43
-
alert has occurred in the protocol, i.e. if the connection has been
44
-
closed cleanly. Note that in this case B<SSL_ERROR_ZERO_RETURN>
45
-
does not necessarily indicate that the underlying transport
46
-
has been closed.
41
+
The TLS/SSL connection has been closed.
42
+
If the protocol version is SSL 3.0 or higher, this result code is returned only
43
+
if a closure alert has occurred in the protocol, i.e. if the connection has been
44
+
closed cleanly.
45
+
Note that in this case B<SSL_ERROR_ZERO_RETURN> does not necessarily
46
+
indicate that the underlying transport has been closed.
47
47
48
48
=item SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE
49
49
@@ -112,12 +112,9 @@ thread has completed.
112
112
113
113
=item SSL_ERROR_SYSCALL
114
114
115
-
Some I/O error occurred. The OpenSSL error queue may contain more
116
-
information on the error. If the error queue is empty
117
-
(i.e. ERR_get_error() returns 0), B<ret> can be used to find out more
118
-
about the error: If B<ret == 0>, an EOF was observed that violates
119
-
the protocol. If B<ret == -1>, the underlying B<BIO> reported an
120
-
I/O error (for socket I/O on Unix systems, consult B<errno> for details).
115
+
Some non-recoverable I/O error occurred.
116
+
The OpenSSL error queue may contain more information on the error.
117
+
For socket I/O on Unix systems, consult B<errno> for details.
121
118
122
119
=item SSL_ERROR_SSL
123
120
Original file line number Diff line number Diff line change
@@ -9,17 +9,17 @@ SSL_read_ex, SSL_read, SSL_peek_ex, SSL_peek
9
9
10
10
#include <openssl/ssl.h>
11
11
12
-
int SSL_read_ex(SSL *ssl, void *buf, size_t num, size_t *read);
12
+
int SSL_read_ex(SSL *ssl, void *buf, size_t num, size_t *readbytes);
13
13
int SSL_read(SSL *ssl, void *buf, int num);
14
14
15
-
int SSL_peek_ex(SSL *ssl, void *buf, size_t num, size_t *read);
15
+
int SSL_peek_ex(SSL *ssl, void *buf, size_t num, size_t *readbytes);
16
16
int SSL_peek(SSL *ssl, void *buf, int num);
17
17
18
18
=head1 DESCRIPTION
19
19
20
20
SSL_read_ex() and SSL_read() try to read B<num> bytes from the specified B<ssl>
21
21
into the buffer B<buf>. On success SSL_read_ex() will store the number of bytes
22
-
actually read in B<*read>.
22
+
actually read in B<*readbytes>.
23
23
24
24
SSL_peek_ex() and SSL_peek() are identical to SSL_read_ex() and SSL_read()
25
25
respectively except no bytes are actually removed from the underlying BIO during
@@ -90,38 +90,32 @@ with the same arguments.
90
90
91
91
SSL_read_ex() and SSL_peek_ex() will return 1 for success or 0 for failure.
92
92
Success means that 1 or more application data bytes have been read from the SSL
93
-
connection. Failure means that no bytes could be read from the SSL connection.
93
+
connection.
94
+
Failure means that no bytes could be read from the SSL connection.
94
95
Failures can be retryable (e.g. we are waiting for more bytes to
95
-
be delivered by the network) or non-retryable (e.g. a fatal network error). In
96
-
the event of a failure call L<SSL_get_error(3)> to find out the reason which
96
+
be delivered by the network) or non-retryable (e.g. a fatal network error).
97
+
In the event of a failure call L<SSL_get_error(3)> to find out the reason which
97
98
indicates whether the call is retryable or not.
98
99
99
100
For SSL_read() and SSL_peek() the following return values can occur:
100
101
101
102
=over 4
102
103
103
-
=item E<gt>0
104
+
=item E<gt> 0
104
105
105
-
The read operation was successful; the return value is the number of
106
-
bytes actually read from the TLS/SSL connection.
106
+
The read operation was successful.
107
+
The return value is the number of bytes actually read from the TLS/SSL
108
+
connection.
107
109
108
-
=item Z<>0
110
+
=item Z<><= 0
109
111
110
-
The read operation was not successful. The reason may either be a clean
111
-
shutdown due to a "close notify" alert sent by the peer (in which case
112
-
the SSL_RECEIVED_SHUTDOWN flag in the ssl shutdown state is set
113
-
(see L<SSL_shutdown(3)>,
114
-
L<SSL_set_shutdown(3)>). It is also possible, that
115
-
the peer simply shut down the underlying transport and the shutdown is
116
-
incomplete. Call SSL_get_error() with the return value B<ret> to find out,
117
-
whether an error occurred or the connection was shut down cleanly
118
-
(SSL_ERROR_ZERO_RETURN).
112
+
The read operation was not successful, because either the connection was closed,
113
+
an error occurred or action must be taken by the calling process.
114
+
Call L<SSL_get_error(3)> with the return value B<ret> to find out the reason.
119
115
120
-
=item E<lt>0
121
-
122
-
The read operation was not successful, because either an error occurred
123
-
or action must be taken by the calling process. Call SSL_get_error() with the
124
-
return value B<ret> to find out the reason.
116
+
Old documentation indicated a difference between 0 and -1, and that -1 was
117
+
retryable.
118
+
You should instead call SSL_get_error() to find out if it's retryable.
125
119
126
120
=back
127
121
Original file line number Diff line number Diff line change
@@ -86,23 +86,20 @@ For SSL_write() the following return values can occur:
86
86
87
87
=over 4
88
88
89
-
=item E<gt>0
89
+
=item E<gt> 0
90
90
91
91
The write operation was successful, the return value is the number of
92
92
bytes actually written to the TLS/SSL connection.
93
93
94
-
=item Z<>0
94
+
=item Z<><= 0
95
95
96
-
The write operation was not successful. Probably the underlying connection
97
-
was closed. Call SSL_get_error() with the return value B<ret> to find out,
98
-
whether an error occurred or the connection was shut down cleanly
99
-
(SSL_ERROR_ZERO_RETURN).
96
+
The write operation was not successful, because either the connection was
97
+
closed, an error occurred or action must be taken by the calling process.
98
+
Call SSL_get_error() with the return value B<ret> to find out the reason.
100
99
101
-
=item E<lt>0
102
-
103
-
The write operation was not successful, because either an error occurred
104
-
or action must be taken by the calling process. Call SSL_get_error() with the
105
-
return value B<ret> to find out the reason.
100
+
Old documentation indicated a difference between 0 and -1, and that -1 was
101
+
retryable.
102
+
You should instead call SSL_get_error() to find out if it's retryable.
106
103
107
104
=back
108
105
Original file line number Diff line number Diff line change
@@ -1580,9 +1580,9 @@ __owur int SSL_get_changed_async_fds(SSL *s, OSSL_ASYNC_FD *addfd,
1580
1580
__owur int SSL_accept(SSL *ssl);
1581
1581
__owur int SSL_connect(SSL *ssl);
1582
1582
__owur int SSL_read(SSL *ssl, void *buf, int num);
1583
-
__owur int SSL_read_ex(SSL *ssl, void *buf, size_t num, size_t *read);
1583
+
__owur int SSL_read_ex(SSL *ssl, void *buf, size_t num, size_t *readbytes);
1584
1584
__owur int SSL_peek(SSL *ssl, void *buf, int num);
1585
-
__owur int SSL_peek_ex(SSL *ssl, void *buf, size_t num, size_t *read);
1585
+
__owur int SSL_peek_ex(SSL *ssl, void *buf, size_t num, size_t *readbytes);
1586
1586
__owur int SSL_write(SSL *ssl, const void *buf, int num);
1587
1587
__owur int SSL_write_ex(SSL *s, const void *buf, size_t num, size_t *written);
1588
1588
long SSL_ctrl(SSL *ssl, int cmd, long larg, void *parg);
Original file line number Diff line number Diff line change
@@ -178,10 +178,7 @@ const char *SSL_rstate_string(const SSL *s)
178
178
}
179
179
180
180
/*
181
-
* Return values are as per SSL_read(), i.e.
182
-
* 1 Success
183
-
* 0 Failure (not retryable)
184
-
* <0 Failure (may be retryable)
181
+
* Return values are as per SSL_read()
185
182
*/
186
183
int ssl3_read_n(SSL *s, size_t n, size_t max, int extend, int clearold,
187
184
size_t *readbytes)
@@ -319,7 +316,7 @@ int ssl3_read_n(SSL *s, size_t n, size_t max, int extend, int clearold,
319
316
if (s->mode & SSL_MODE_RELEASE_BUFFERS && !SSL_IS_DTLS(s))
320
317
if (len + left == 0)
321
318
ssl3_release_read_buffer(s);
322
-
return -1;
319
+
return ret;
323
320
}
324
321
left += bioread;
325
322
/*
@@ -897,10 +894,7 @@ int do_ssl3_write(SSL *s, int type, const unsigned char *buf,
897
894
898
895
/* if s->s3->wbuf.left != 0, we need to call this
899
896
*
900
-
* Return values are as per SSL_read(), i.e.
901
-
* 1 Success
902
-
* 0 Failure (not retryable)
903
-
* <0 Failure (may be retryable)
897
+
* Return values are as per SSL_write()
904
898
*/
905
899
int ssl3_write_pending(SSL *s, int type, const unsigned char *buf, size_t len,
906
900
size_t *written)
@@ -955,7 +949,7 @@ int ssl3_write_pending(SSL *s, int type, const unsigned char *buf, size_t len,
955
949
*/
956
950
SSL3_BUFFER_set_left(&wb[currbuf], 0);
957
951
}
958
-
return -1;
952
+
return (i);
959
953
}
960
954
SSL3_BUFFER_add_offset(&wb[currbuf], tmpwrit);
961
955
SSL3_BUFFER_sub_left(&wb[currbuf], tmpwrit);
Original file line number Diff line number Diff line change
@@ -297,32 +297,59 @@ int main(int argc, char *argv[])
297
297
* we hit at least one async event in both reading and writing
298
298
*/
299
299
for (j = 0; j < 2; j++) {
300
+
int len;
301
+
300
302
/*
301
303
* Write some test data. It should never take more than 2 attempts
302
-
* (the first one might be a retryable fail). A zero return from
303
-
* SSL_write() is a non-retryable failure, so fail immediately if
304
-
* we get that.
304
+
* (the first one might be a retryable fail).
305
305
*/
306
-
for (ret = -1, i = 0; ret < 0 && i < 2 * sizeof(testdata); i++)
307
-
ret = SSL_write(clientssl, testdata, sizeof(testdata));
308
-
if (ret <= 0) {
309
-
printf("Test %d failed: Failed to write app data\n", test);
306
+
for (ret = -1, i = 0, len = 0; len != sizeof(testdata) && i < 2;
307
+
i++) {
308
+
ret = SSL_write(clientssl, testdata + len,
309
+
sizeof(testdata) - len);
310
+
if (ret > 0) {
311
+
len += ret;
312
+
} else {
313
+
int ssl_error = SSL_get_error(clientssl, ret);
314
+
315
+
if (ssl_error == SSL_ERROR_SYSCALL ||
316
+
ssl_error == SSL_ERROR_SSL) {
317
+
printf("Test %d failed: Failed to write app data\n", test);
318
+
err = -1;
319
+
goto end;
320
+
}
321
+
}
322
+
}
323
+
if (len != sizeof(testdata)) {
324
+
err = -1;
325
+
printf("Test %d failed: Failed to write all app data\n", test);
310
326
goto end;
311
327
}
312
328
/*
313
329
* Now read the test data. It may take more attemps here because
314
330
* it could fail once for each byte read, including all overhead
315
-
* bytes from the record header/padding etc. Fail immediately if we
316
-
* get a zero return from SSL_read().
331
+
* bytes from the record header/padding etc.
317
332
*/
318
-
for (ret = -1, i = 0; ret < 0 && i < MAX_ATTEMPTS; i++)
319
-
ret = SSL_read(serverssl, buf, sizeof(buf));
320
-
if (ret <= 0) {
321
-
printf("Test %d failed: Failed to read app data\n", test);
322
-
goto end;
333
+
for (ret = -1, i = 0, len = 0; len != sizeof(testdata) &&
334
+
i < MAX_ATTEMPTS; i++)
335
+
{
336
+
ret = SSL_read(serverssl, buf + len, sizeof(buf) - len);
337
+
if (ret > 0) {
338
+
len += ret;
339
+
} else {
340
+
int ssl_error = SSL_get_error(serverssl, ret);
341
+
342
+
if (ssl_error == SSL_ERROR_SYSCALL ||
343
+
ssl_error == SSL_ERROR_SSL) {
344
+
printf("Test %d failed: Failed to read app data\n", test);
345
+
err = -1;
346
+
goto end;
347
+
}
348
+
}
323
349
}
324
-
if (ret != sizeof(testdata)
350
+
if (len != sizeof(testdata)
325
351
|| memcmp(buf, testdata, sizeof(testdata)) != 0) {
352
+
err = -1;
326
353
printf("Test %d failed: Unexpected app data received\n", test);
327
354
goto end;
328
355
}
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4