]>
Commit | Line | Data |
---|---|---|
d4defa1a DW |
1 | Upstream issue 18345 |
2 | Link: https://issues.asterisk.org/jira/browse/ASTERISK-18345 | |
3 | Patch-By: Filip Jenicek | |
4 | ||
5 | Submitted upstream: 2012-05-31 09:12 | |
6 | For Asterisk version: 1.8.4 | |
7 | ||
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. | |
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'; |