2 Link: https://issues.asterisk.org/jira/browse/ASTERISK-18345
3 Patch-By: Filip Jenicek
5 Submitted upstream: 2012-05-31 09:12
6 For Asterisk version: 1.8.4
8 The HOOK_T ssl_read function should behave the same way as the system read function
9 by blocking and waiting for (more) data from the SSL subsystem. Failure to do this
10 will drop data on the floor and ultimately disconnect SSL clients.
12 --- asterisk/main/tcptls.c
13 +++ asterisk/main/tcptls.c
15 static HOOK_T ssl_read(void *cookie, char *buf, LEN_T len)
17 int i = SSL_read(cookie, buf, len-1);
19 + /* ssl_read should block and wait for the SSL layer to provide all data */
20 + while (i < 0 && SSL_get_error(cookie, i) == SSL_ERROR_WANT_READ) {
21 + ast_debug(1, "SSL_read - data not ready.\n");
22 + if (ast_wait_for_input(SSL_get_fd(cookie), 5000) <= 0) return 0;
23 + i = SSL_read(cookie, buf, len-1);