This commit is contained in:
Dirk Wagner
2014-06-09 12:20:21 +02:00
parent c10ef4bd39
commit 5e55b70d26
2 changed files with 36 additions and 7 deletions

View File

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