| | @@ -811,10 +811,11 @@ |
| 811 | 811 | } |
| 812 | 812 | |
| 813 | 813 | /* |
| 814 | 814 | ** Read cleartext bytes that have been received from the client and |
| 815 | 815 | ** decrypted by the SSL server codec. |
| 816 | +** Return (size_t)-1 on error. |
| 816 | 817 | */ |
| 817 | 818 | size_t ssl_read_server(void *pServerArg, char *zBuf, size_t nBuf){ |
| 818 | 819 | int n; |
| 819 | 820 | size_t rc = 0; |
| 820 | 821 | SslServerConn *pServer = (SslServerConn*)pServerArg; |
| | @@ -821,21 +822,28 @@ |
| 821 | 822 | if( nBuf>0x7fffffff ){ fossil_fatal("SSL read too big"); } |
| 822 | 823 | else if( BIO_eof(pServer->bio) ) return 0; |
| 823 | 824 | while( nBuf!=rc ){ |
| 824 | 825 | n = SSL_read(pServer->ssl, zBuf + rc, (int)(nBuf - rc)); |
| 825 | 826 | if( n<=0 ){ |
| 826 | | - break; |
| 827 | + int error = SSL_get_error(pServer->ssl,n); |
| 828 | + switch( error ){ |
| 829 | + case SSL_ERROR_NONE: |
| 830 | + case SSL_ERROR_ZERO_RETURN: |
| 831 | + /* Not all errors relevant with SSL_MODE_AUTO_RETRY. */ |
| 832 | + case SSL_ERROR_WANT_READ: |
| 833 | + case SSL_ERROR_WANT_WRITE: |
| 834 | + case SSL_ERROR_WANT_CONNECT: |
| 835 | + case SSL_ERROR_WANT_ACCEPT: |
| 836 | + return rc; |
| 837 | + default: |
| 838 | + return (size_t)-1; |
| 839 | + } |
| 827 | 840 | }else if(n>0){ |
| 828 | 841 | rc += n; |
| 829 | | - } |
| 830 | | -#ifdef _WIN32 |
| 831 | | - /* Windows (XP and 10 tested with openssl 1.1.1m and 3.0.1) does |
| 832 | | - ** not require reading in a loop, returning all data in a single |
| 833 | | - ** call. If we read in a loop on Windows, SSL reads fail. Details: |
| 834 | | - ** https://fossil-scm.org/forum/forumpost/2f818850abb72719 */ |
| 835 | | - break; |
| 836 | | -#endif |
| 842 | + /* SSL_read() returns at most 16 KB of data, so retry in this case. */ |
| 843 | + if( n!=16384 ) break; |
| 844 | + } |
| 837 | 845 | } |
| 838 | 846 | return rc; |
| 839 | 847 | } |
| 840 | 848 | |
| 841 | 849 | /* |
| 842 | 850 | |