Fossil SCM

ssl_read_server() now returns 0 on read error and lets the higher-level code deal with the short read. This might resolve the issue under discussion in [forum:/forumpost/2f818850abb72719 | forum post 2f818850abb72719].

stephan 2022-01-25 18:14 trunk
Commit acffc8f7858254ebb5c0c06b6af79fbc56085d5d4740047ca5aa46dc89e31689
2 files changed +3 -1 +1 -3
+3 -1
--- src/cgi.c
+++ src/cgi.c
@@ -1383,11 +1383,13 @@
13831383
*/
13841384
cgi_set_content_type(json_guess_content_type());
13851385
}
13861386
#endif /* FOSSIL_ENABLE_JSON */
13871387
else{
1388
- blob_read_from_cgi(&g.cgiIn, len);
1388
+ if( blob_read_from_cgi(&g.cgiIn, len)!=len ){
1389
+ malformed_request("CGI content-length mismatch");
1390
+ }
13891391
}
13901392
}
13911393
}
13921394
13931395
/*
13941396
--- src/cgi.c
+++ src/cgi.c
@@ -1383,11 +1383,13 @@
1383 */
1384 cgi_set_content_type(json_guess_content_type());
1385 }
1386 #endif /* FOSSIL_ENABLE_JSON */
1387 else{
1388 blob_read_from_cgi(&g.cgiIn, len);
 
 
1389 }
1390 }
1391 }
1392
1393 /*
1394
--- src/cgi.c
+++ src/cgi.c
@@ -1383,11 +1383,13 @@
1383 */
1384 cgi_set_content_type(json_guess_content_type());
1385 }
1386 #endif /* FOSSIL_ENABLE_JSON */
1387 else{
1388 if( blob_read_from_cgi(&g.cgiIn, len)!=len ){
1389 malformed_request("CGI content-length mismatch");
1390 }
1391 }
1392 }
1393 }
1394
1395 /*
1396
+1 -3
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -820,16 +820,14 @@
820820
SslServerConn *pServer = (SslServerConn*)pServerArg;
821821
if( nBuf>0x7fffffff ){ fossil_fatal("SSL read too big"); }
822822
else if( BIO_eof(pServer->bio) ) return 0;
823823
while( nBuf!=rc ){
824824
n = SSL_read(pServer->ssl, zBuf + rc, (int)(nBuf - rc));
825
- if( n==0 ){
825
+ if( n<=0 ){
826826
break;
827827
}else if(n>0){
828828
rc += n;
829
- }else{
830
- fossil_fatal("SSL read error.");
831829
}
832830
#ifdef _WIN32
833831
/* Windows (XP and 10 tested with openssl 1.1.1m and 3.0.1) does
834832
** not require reading in a loop, returning all data in a single
835833
** call. If we read in a loop on Windows, SSL reads fail. Details:
836834
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -820,16 +820,14 @@
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 if( n==0 ){
826 break;
827 }else if(n>0){
828 rc += n;
829 }else{
830 fossil_fatal("SSL read error.");
831 }
832 #ifdef _WIN32
833 /* Windows (XP and 10 tested with openssl 1.1.1m and 3.0.1) does
834 ** not require reading in a loop, returning all data in a single
835 ** call. If we read in a loop on Windows, SSL reads fail. Details:
836
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -820,16 +820,14 @@
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 if( n<=0 ){
826 break;
827 }else if(n>0){
828 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

Keyboard Shortcuts

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