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).

stephan 2022-01-24 08:23 trunk
Commit b890451cfbf892e11fd94127c25873b966b16e9f69e3751373a4567df9eba734
1 file changed +12 -5
+12 -5
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -813,26 +813,33 @@
813813
/*
814814
** Read cleartext bytes that have been received from the client and
815815
** decrypted by the SSL server codec.
816816
*/
817817
size_t ssl_read_server(void *pServerArg, char *zBuf, size_t nBuf){
818
- int n, err = 0;
818
+ int n;
819819
size_t rc = 0;
820820
SslServerConn *pServer = (SslServerConn*)pServerArg;
821821
if( nBuf>0x7fffffff ){ fossil_fatal("SSL read too big"); }
822822
else if( BIO_eof(pServer->bio) ) return 0;
823
- while( 0==err && nBuf!=rc ){
823
+ while( nBuf!=rc ){
824824
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
825833
if( n==0 ){
826834
break;
827
- }
828
- err = SSL_get_error(pServer->ssl, n);
829
- if(0==err){
835
+ }else if(n>0){
830836
rc += n;
831837
}else{
832838
fossil_fatal("SSL read error.");
833839
}
840
+#endif
834841
}
835842
return rc;
836843
}
837844
838845
/*
839846
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button