Fossil SCM

merge latest trunk

rdb 2022-01-16 11:29 tls-server-fix merge
Commit 8dde27776839648293b3803dced9783180ea3fbd8757d5be1334d6e27a35c0de
+19 -5
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -752,10 +752,11 @@
752752
753753
typedef struct SslServerConn {
754754
SSL *ssl; /* The SSL codec */
755755
int atEof; /* True when EOF reached. */
756756
int iSocket; /* The socket */
757
+ BIO *bio; /* BIO object. Needed for EOF detection. */
757758
} SslServerConn;
758759
759760
/*
760761
** Create a new server-side codec. The argument is the socket's file
761762
** descriptor from which the codec reads and writes. The returned
@@ -765,10 +766,11 @@
765766
SslServerConn *pServer = fossil_malloc_zero(sizeof(*pServer));
766767
BIO *b = BIO_new_socket(iSocket, 0);
767768
pServer->ssl = SSL_new(sslCtx);
768769
pServer->atEof = 0;
769770
pServer->iSocket = iSocket;
771
+ pServer->bio = b;
770772
SSL_set_bio(pServer->ssl, b, b);
771773
SSL_accept(pServer->ssl);
772774
return (void*)pServer;
773775
}
774776
@@ -793,17 +795,29 @@
793795
/*
794796
** Read cleartext bytes that have been received from the client and
795797
** decrypted by the SSL server codec.
796798
*/
797799
size_t ssl_read_server(void *pServerArg, char *zBuf, size_t nBuf){
798
- int n;
800
+ int n, err = 0;
801
+ size_t rc = 0;
799802
SslServerConn *pServer = (SslServerConn*)pServerArg;
800
- if( pServer->atEof ) return 0;
801803
if( nBuf>0x7fffffff ){ fossil_fatal("SSL read too big"); }
802
- n = SSL_read(pServer->ssl, zBuf, (int)nBuf);
803
- if( n==0 ) pServer->atEof = 1;
804
- return n<=0 ? 0 : n;
804
+ while( 0==err && nBuf!=rc && 0==pServer->atEof ){
805
+ n = SSL_read(pServer->ssl, zBuf + rc, (int)(nBuf - rc));
806
+ if( n==0 ){
807
+ pServer->atEof = 1;
808
+ break;
809
+ }
810
+ err = SSL_get_error(pServer->ssl, n);
811
+ if(0==err){
812
+ rc += n;
813
+ pServer->atEof = BIO_eof(pServer->bio);
814
+ }else{
815
+ fossil_fatal("SSL read error.");
816
+ }
817
+ }
818
+ return rc;
805819
}
806820
807821
/*
808822
** Read a single line of text from the client.
809823
*/
810824
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -752,10 +752,11 @@
752
753 typedef struct SslServerConn {
754 SSL *ssl; /* The SSL codec */
755 int atEof; /* True when EOF reached. */
756 int iSocket; /* The socket */
 
757 } SslServerConn;
758
759 /*
760 ** Create a new server-side codec. The argument is the socket's file
761 ** descriptor from which the codec reads and writes. The returned
@@ -765,10 +766,11 @@
765 SslServerConn *pServer = fossil_malloc_zero(sizeof(*pServer));
766 BIO *b = BIO_new_socket(iSocket, 0);
767 pServer->ssl = SSL_new(sslCtx);
768 pServer->atEof = 0;
769 pServer->iSocket = iSocket;
 
770 SSL_set_bio(pServer->ssl, b, b);
771 SSL_accept(pServer->ssl);
772 return (void*)pServer;
773 }
774
@@ -793,17 +795,29 @@
793 /*
794 ** Read cleartext bytes that have been received from the client and
795 ** decrypted by the SSL server codec.
796 */
797 size_t ssl_read_server(void *pServerArg, char *zBuf, size_t nBuf){
798 int n;
 
799 SslServerConn *pServer = (SslServerConn*)pServerArg;
800 if( pServer->atEof ) return 0;
801 if( nBuf>0x7fffffff ){ fossil_fatal("SSL read too big"); }
802 n = SSL_read(pServer->ssl, zBuf, (int)nBuf);
803 if( n==0 ) pServer->atEof = 1;
804 return n<=0 ? 0 : n;
 
 
 
 
 
 
 
 
 
 
 
 
805 }
806
807 /*
808 ** Read a single line of text from the client.
809 */
810
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -752,10 +752,11 @@
752
753 typedef struct SslServerConn {
754 SSL *ssl; /* The SSL codec */
755 int atEof; /* True when EOF reached. */
756 int iSocket; /* The socket */
757 BIO *bio; /* BIO object. Needed for EOF detection. */
758 } SslServerConn;
759
760 /*
761 ** Create a new server-side codec. The argument is the socket's file
762 ** descriptor from which the codec reads and writes. The returned
@@ -765,10 +766,11 @@
766 SslServerConn *pServer = fossil_malloc_zero(sizeof(*pServer));
767 BIO *b = BIO_new_socket(iSocket, 0);
768 pServer->ssl = SSL_new(sslCtx);
769 pServer->atEof = 0;
770 pServer->iSocket = iSocket;
771 pServer->bio = b;
772 SSL_set_bio(pServer->ssl, b, b);
773 SSL_accept(pServer->ssl);
774 return (void*)pServer;
775 }
776
@@ -793,17 +795,29 @@
795 /*
796 ** Read cleartext bytes that have been received from the client and
797 ** decrypted by the SSL server codec.
798 */
799 size_t ssl_read_server(void *pServerArg, char *zBuf, size_t nBuf){
800 int n, err = 0;
801 size_t rc = 0;
802 SslServerConn *pServer = (SslServerConn*)pServerArg;
 
803 if( nBuf>0x7fffffff ){ fossil_fatal("SSL read too big"); }
804 while( 0==err && nBuf!=rc && 0==pServer->atEof ){
805 n = SSL_read(pServer->ssl, zBuf + rc, (int)(nBuf - rc));
806 if( n==0 ){
807 pServer->atEof = 1;
808 break;
809 }
810 err = SSL_get_error(pServer->ssl, n);
811 if(0==err){
812 rc += n;
813 pServer->atEof = BIO_eof(pServer->bio);
814 }else{
815 fossil_fatal("SSL read error.");
816 }
817 }
818 return rc;
819 }
820
821 /*
822 ** Read a single line of text from the client.
823 */
824
+19 -5
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -752,10 +752,11 @@
752752
753753
typedef struct SslServerConn {
754754
SSL *ssl; /* The SSL codec */
755755
int atEof; /* True when EOF reached. */
756756
int iSocket; /* The socket */
757
+ BIO *bio; /* BIO object. Needed for EOF detection. */
757758
} SslServerConn;
758759
759760
/*
760761
** Create a new server-side codec. The argument is the socket's file
761762
** descriptor from which the codec reads and writes. The returned
@@ -765,10 +766,11 @@
765766
SslServerConn *pServer = fossil_malloc_zero(sizeof(*pServer));
766767
BIO *b = BIO_new_socket(iSocket, 0);
767768
pServer->ssl = SSL_new(sslCtx);
768769
pServer->atEof = 0;
769770
pServer->iSocket = iSocket;
771
+ pServer->bio = b;
770772
SSL_set_bio(pServer->ssl, b, b);
771773
SSL_accept(pServer->ssl);
772774
return (void*)pServer;
773775
}
774776
@@ -793,17 +795,29 @@
793795
/*
794796
** Read cleartext bytes that have been received from the client and
795797
** decrypted by the SSL server codec.
796798
*/
797799
size_t ssl_read_server(void *pServerArg, char *zBuf, size_t nBuf){
798
- int n;
800
+ int n, err = 0;
801
+ size_t rc = 0;
799802
SslServerConn *pServer = (SslServerConn*)pServerArg;
800
- if( pServer->atEof ) return 0;
801803
if( nBuf>0x7fffffff ){ fossil_fatal("SSL read too big"); }
802
- n = SSL_read(pServer->ssl, zBuf, (int)nBuf);
803
- if( n==0 ) pServer->atEof = 1;
804
- return n<=0 ? 0 : n;
804
+ while( 0==err && nBuf!=rc && 0==pServer->atEof ){
805
+ n = SSL_read(pServer->ssl, zBuf + rc, (int)(nBuf - rc));
806
+ if( n==0 ){
807
+ pServer->atEof = 1;
808
+ break;
809
+ }
810
+ err = SSL_get_error(pServer->ssl, n);
811
+ if(0==err){
812
+ rc += n;
813
+ pServer->atEof = BIO_eof(pServer->bio);
814
+ }else{
815
+ fossil_fatal("SSL read error.");
816
+ }
817
+ }
818
+ return rc;
805819
}
806820
807821
/*
808822
** Read a single line of text from the client.
809823
*/
810824
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -752,10 +752,11 @@
752
753 typedef struct SslServerConn {
754 SSL *ssl; /* The SSL codec */
755 int atEof; /* True when EOF reached. */
756 int iSocket; /* The socket */
 
757 } SslServerConn;
758
759 /*
760 ** Create a new server-side codec. The argument is the socket's file
761 ** descriptor from which the codec reads and writes. The returned
@@ -765,10 +766,11 @@
765 SslServerConn *pServer = fossil_malloc_zero(sizeof(*pServer));
766 BIO *b = BIO_new_socket(iSocket, 0);
767 pServer->ssl = SSL_new(sslCtx);
768 pServer->atEof = 0;
769 pServer->iSocket = iSocket;
 
770 SSL_set_bio(pServer->ssl, b, b);
771 SSL_accept(pServer->ssl);
772 return (void*)pServer;
773 }
774
@@ -793,17 +795,29 @@
793 /*
794 ** Read cleartext bytes that have been received from the client and
795 ** decrypted by the SSL server codec.
796 */
797 size_t ssl_read_server(void *pServerArg, char *zBuf, size_t nBuf){
798 int n;
 
799 SslServerConn *pServer = (SslServerConn*)pServerArg;
800 if( pServer->atEof ) return 0;
801 if( nBuf>0x7fffffff ){ fossil_fatal("SSL read too big"); }
802 n = SSL_read(pServer->ssl, zBuf, (int)nBuf);
803 if( n==0 ) pServer->atEof = 1;
804 return n<=0 ? 0 : n;
 
 
 
 
 
 
 
 
 
 
 
 
805 }
806
807 /*
808 ** Read a single line of text from the client.
809 */
810
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -752,10 +752,11 @@
752
753 typedef struct SslServerConn {
754 SSL *ssl; /* The SSL codec */
755 int atEof; /* True when EOF reached. */
756 int iSocket; /* The socket */
757 BIO *bio; /* BIO object. Needed for EOF detection. */
758 } SslServerConn;
759
760 /*
761 ** Create a new server-side codec. The argument is the socket's file
762 ** descriptor from which the codec reads and writes. The returned
@@ -765,10 +766,11 @@
766 SslServerConn *pServer = fossil_malloc_zero(sizeof(*pServer));
767 BIO *b = BIO_new_socket(iSocket, 0);
768 pServer->ssl = SSL_new(sslCtx);
769 pServer->atEof = 0;
770 pServer->iSocket = iSocket;
771 pServer->bio = b;
772 SSL_set_bio(pServer->ssl, b, b);
773 SSL_accept(pServer->ssl);
774 return (void*)pServer;
775 }
776
@@ -793,17 +795,29 @@
795 /*
796 ** Read cleartext bytes that have been received from the client and
797 ** decrypted by the SSL server codec.
798 */
799 size_t ssl_read_server(void *pServerArg, char *zBuf, size_t nBuf){
800 int n, err = 0;
801 size_t rc = 0;
802 SslServerConn *pServer = (SslServerConn*)pServerArg;
 
803 if( nBuf>0x7fffffff ){ fossil_fatal("SSL read too big"); }
804 while( 0==err && nBuf!=rc && 0==pServer->atEof ){
805 n = SSL_read(pServer->ssl, zBuf + rc, (int)(nBuf - rc));
806 if( n==0 ){
807 pServer->atEof = 1;
808 break;
809 }
810 err = SSL_get_error(pServer->ssl, n);
811 if(0==err){
812 rc += n;
813 pServer->atEof = BIO_eof(pServer->bio);
814 }else{
815 fossil_fatal("SSL read error.");
816 }
817 }
818 return rc;
819 }
820
821 /*
822 ** Read a single line of text from the client.
823 */
824
+2
--- src/main.c
+++ src/main.c
@@ -3293,10 +3293,12 @@
32933293
if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
32943294
db_close(1);
32953295
32963296
/* Start up an HTTP server
32973297
*/
3298
+ fossil_setenv("SERVER_SOFTWARE", "fossil version " RELEASE_VERSION
3299
+ " " MANIFEST_VERSION " " MANIFEST_DATE);
32983300
#if !defined(_WIN32)
32993301
/* Unix implementation */
33003302
if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
33013303
fossil_fatal("unable to listen on TCP socket %d", iPort);
33023304
}
33033305
--- src/main.c
+++ src/main.c
@@ -3293,10 +3293,12 @@
3293 if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
3294 db_close(1);
3295
3296 /* Start up an HTTP server
3297 */
 
 
3298 #if !defined(_WIN32)
3299 /* Unix implementation */
3300 if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
3301 fossil_fatal("unable to listen on TCP socket %d", iPort);
3302 }
3303
--- src/main.c
+++ src/main.c
@@ -3293,10 +3293,12 @@
3293 if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
3294 db_close(1);
3295
3296 /* Start up an HTTP server
3297 */
3298 fossil_setenv("SERVER_SOFTWARE", "fossil version " RELEASE_VERSION
3299 " " MANIFEST_VERSION " " MANIFEST_DATE);
3300 #if !defined(_WIN32)
3301 /* Unix implementation */
3302 if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
3303 fossil_fatal("unable to listen on TCP socket %d", iPort);
3304 }
3305
+2
--- src/main.c
+++ src/main.c
@@ -3293,10 +3293,12 @@
32933293
if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
32943294
db_close(1);
32953295
32963296
/* Start up an HTTP server
32973297
*/
3298
+ fossil_setenv("SERVER_SOFTWARE", "fossil version " RELEASE_VERSION
3299
+ " " MANIFEST_VERSION " " MANIFEST_DATE);
32983300
#if !defined(_WIN32)
32993301
/* Unix implementation */
33003302
if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
33013303
fossil_fatal("unable to listen on TCP socket %d", iPort);
33023304
}
33033305
--- src/main.c
+++ src/main.c
@@ -3293,10 +3293,12 @@
3293 if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
3294 db_close(1);
3295
3296 /* Start up an HTTP server
3297 */
 
 
3298 #if !defined(_WIN32)
3299 /* Unix implementation */
3300 if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
3301 fossil_fatal("unable to listen on TCP socket %d", iPort);
3302 }
3303
--- src/main.c
+++ src/main.c
@@ -3293,10 +3293,12 @@
3293 if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
3294 db_close(1);
3295
3296 /* Start up an HTTP server
3297 */
3298 fossil_setenv("SERVER_SOFTWARE", "fossil version " RELEASE_VERSION
3299 " " MANIFEST_VERSION " " MANIFEST_DATE);
3300 #if !defined(_WIN32)
3301 /* Unix implementation */
3302 if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
3303 fossil_fatal("unable to listen on TCP socket %d", iPort);
3304 }
3305
--- src/style.c
+++ src/style.c
@@ -1394,10 +1394,11 @@
13941394
#endif
13951395
@ cgi_csrf_safe(0) = %d(cgi_csrf_safe(0))<br />
13961396
@ fossil_exe_id() = %h(fossil_exe_id())<br />
13971397
@ <hr />
13981398
P("HTTP_USER_AGENT");
1399
+ P("SERVER_SOFTWARE");
13991400
cgi_print_all(showAll, 0);
14001401
if( showAll && blob_size(&g.httpHeader)>0 ){
14011402
@ <hr />
14021403
@ <pre>
14031404
@ %h(blob_str(&g.httpHeader))
14041405
--- src/style.c
+++ src/style.c
@@ -1394,10 +1394,11 @@
1394 #endif
1395 @ cgi_csrf_safe(0) = %d(cgi_csrf_safe(0))<br />
1396 @ fossil_exe_id() = %h(fossil_exe_id())<br />
1397 @ <hr />
1398 P("HTTP_USER_AGENT");
 
1399 cgi_print_all(showAll, 0);
1400 if( showAll && blob_size(&g.httpHeader)>0 ){
1401 @ <hr />
1402 @ <pre>
1403 @ %h(blob_str(&g.httpHeader))
1404
--- src/style.c
+++ src/style.c
@@ -1394,10 +1394,11 @@
1394 #endif
1395 @ cgi_csrf_safe(0) = %d(cgi_csrf_safe(0))<br />
1396 @ fossil_exe_id() = %h(fossil_exe_id())<br />
1397 @ <hr />
1398 P("HTTP_USER_AGENT");
1399 P("SERVER_SOFTWARE");
1400 cgi_print_all(showAll, 0);
1401 if( showAll && blob_size(&g.httpHeader)>0 ){
1402 @ <hr />
1403 @ <pre>
1404 @ %h(blob_str(&g.httpHeader))
1405

Keyboard Shortcuts

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