]> git.ipfire.org Git - ipfire-2.x.git/blame - src/patches/asterisk-ssl-reader-should-block.patch
suricata: Fix amount of listened nfqueues
[ipfire-2.x.git] / src / patches / asterisk-ssl-reader-should-block.patch
CommitLineData
d4defa1a
DW
1Upstream issue 18345
2Link: https://issues.asterisk.org/jira/browse/ASTERISK-18345
3Patch-By: Filip Jenicek
4
5Submitted upstream: 2012-05-31 09:12
6For Asterisk version: 1.8.4
7
8The HOOK_T ssl_read function should behave the same way as the system read function
9by blocking and waiting for (more) data from the SSL subsystem. Failure to do this
10will drop data on the floor and ultimately disconnect SSL clients.
11
12--- asterisk/main/tcptls.c
13+++ asterisk/main/tcptls.c
14@@ -55,6 +55,14 @@
15 static HOOK_T ssl_read(void *cookie, char *buf, LEN_T len)
16 {
17 int i = SSL_read(cookie, buf, len-1);
18+
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);
24+ }
25+
26 #if 0
27 if (i >= 0)
28 buf[i] = '\0';