Fossil SCM
Preliminary workaround for Windows-specific SSL_read() behavior described in [forum:/forumpost/2f818850abb72719 | forum post 2f818850abb72719]. Patch tested by Florian (Windows) and myself (Linux).
Commit
b890451cfbf892e11fd94127c25873b966b16e9f69e3751373a4567df9eba734
Parent
06e300e5bd32579…
1 file changed
+12
-5
+12
-5
| --- src/http_ssl.c | ||
| +++ src/http_ssl.c | ||
| @@ -813,26 +813,33 @@ | ||
| 813 | 813 | /* |
| 814 | 814 | ** Read cleartext bytes that have been received from the client and |
| 815 | 815 | ** decrypted by the SSL server codec. |
| 816 | 816 | */ |
| 817 | 817 | size_t ssl_read_server(void *pServerArg, char *zBuf, size_t nBuf){ |
| 818 | - int n, err = 0; | |
| 818 | + int n; | |
| 819 | 819 | size_t rc = 0; |
| 820 | 820 | SslServerConn *pServer = (SslServerConn*)pServerArg; |
| 821 | 821 | if( nBuf>0x7fffffff ){ fossil_fatal("SSL read too big"); } |
| 822 | 822 | else if( BIO_eof(pServer->bio) ) return 0; |
| 823 | - while( 0==err && nBuf!=rc ){ | |
| 823 | + while( nBuf!=rc ){ | |
| 824 | 824 | n = SSL_read(pServer->ssl, zBuf + rc, (int)(nBuf - rc)); |
| 825 | +#ifdef _WIN32 | |
| 826 | + /* Windows (XP and 10 tested with openssl 1.1.1m and 3.0.1) does | |
| 827 | + ** not require reading in a loop, returning all data in a single | |
| 828 | + ** call. If we read in a loop on Windows, SSL reads fail. Details: | |
| 829 | + ** https://fossil-scm.org/forum/forumpost/2f818850abb72719 */ | |
| 830 | + rc += n; | |
| 831 | + break; | |
| 832 | +#else | |
| 825 | 833 | if( n==0 ){ |
| 826 | 834 | break; |
| 827 | - } | |
| 828 | - err = SSL_get_error(pServer->ssl, n); | |
| 829 | - if(0==err){ | |
| 835 | + }else if(n>0){ | |
| 830 | 836 | rc += n; |
| 831 | 837 | }else{ |
| 832 | 838 | fossil_fatal("SSL read error."); |
| 833 | 839 | } |
| 840 | +#endif | |
| 834 | 841 | } |
| 835 | 842 | return rc; |
| 836 | 843 | } |
| 837 | 844 | |
| 838 | 845 | /* |
| 839 | 846 |
| --- src/http_ssl.c | |
| +++ src/http_ssl.c | |
| @@ -813,26 +813,33 @@ | |
| 813 | /* |
| 814 | ** Read cleartext bytes that have been received from the client and |
| 815 | ** decrypted by the SSL server codec. |
| 816 | */ |
| 817 | size_t ssl_read_server(void *pServerArg, char *zBuf, size_t nBuf){ |
| 818 | int n, err = 0; |
| 819 | size_t rc = 0; |
| 820 | SslServerConn *pServer = (SslServerConn*)pServerArg; |
| 821 | if( nBuf>0x7fffffff ){ fossil_fatal("SSL read too big"); } |
| 822 | else if( BIO_eof(pServer->bio) ) return 0; |
| 823 | while( 0==err && nBuf!=rc ){ |
| 824 | n = SSL_read(pServer->ssl, zBuf + rc, (int)(nBuf - rc)); |
| 825 | if( n==0 ){ |
| 826 | break; |
| 827 | } |
| 828 | err = SSL_get_error(pServer->ssl, n); |
| 829 | if(0==err){ |
| 830 | rc += n; |
| 831 | }else{ |
| 832 | fossil_fatal("SSL read error."); |
| 833 | } |
| 834 | } |
| 835 | return rc; |
| 836 | } |
| 837 | |
| 838 | /* |
| 839 |
| --- src/http_ssl.c | |
| +++ src/http_ssl.c | |
| @@ -813,26 +813,33 @@ | |
| 813 | /* |
| 814 | ** Read cleartext bytes that have been received from the client and |
| 815 | ** decrypted by the SSL server codec. |
| 816 | */ |
| 817 | size_t ssl_read_server(void *pServerArg, char *zBuf, size_t nBuf){ |
| 818 | int n; |
| 819 | size_t rc = 0; |
| 820 | SslServerConn *pServer = (SslServerConn*)pServerArg; |
| 821 | if( nBuf>0x7fffffff ){ fossil_fatal("SSL read too big"); } |
| 822 | else if( BIO_eof(pServer->bio) ) return 0; |
| 823 | while( nBuf!=rc ){ |
| 824 | n = SSL_read(pServer->ssl, zBuf + rc, (int)(nBuf - rc)); |
| 825 | #ifdef _WIN32 |
| 826 | /* Windows (XP and 10 tested with openssl 1.1.1m and 3.0.1) does |
| 827 | ** not require reading in a loop, returning all data in a single |
| 828 | ** call. If we read in a loop on Windows, SSL reads fail. Details: |
| 829 | ** https://fossil-scm.org/forum/forumpost/2f818850abb72719 */ |
| 830 | rc += n; |
| 831 | break; |
| 832 | #else |
| 833 | if( n==0 ){ |
| 834 | break; |
| 835 | }else if(n>0){ |
| 836 | rc += n; |
| 837 | }else{ |
| 838 | fossil_fatal("SSL read error."); |
| 839 | } |
| 840 | #endif |
| 841 | } |
| 842 | return rc; |
| 843 | } |
| 844 | |
| 845 | /* |
| 846 |