Fossil

Diff
Login

Diff

Differences From Artifact [feb548774f]:

To Artifact [15be2cd9e7]:


809
810
811
812
813
814
815



816
817

818
819
820
821
822
823
824
825
826
827
828

829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
809
810
811
812
813
814
815
816
817
818
819

820
821
822
823
824
825
826
827
828
829
830
831
832
833







834
835
836
837
838
839
840







+
+
+

-
+











+

-
-
-
-
-
-
-







  SslServerConn *pServer = (SslServerConn*)pServerArg;
  return BIO_eof(pServer->bio);
}

/*
** Read cleartext bytes that have been received from the client and
** decrypted by the SSL server codec.
** If the expected payload size unknown, i.e. if the HTTP Content-Length: header
** field has not been parsed, the noLoop argument should be 1, or SSL_read() may
** block and wait for more data than is eventually going to arrive (on Windows).
*/
size_t ssl_read_server(void *pServerArg, char *zBuf, size_t nBuf){
size_t ssl_read_server(void *pServerArg, char *zBuf, size_t nBuf, int noLoop){
  int n;
  size_t rc = 0;
  SslServerConn *pServer = (SslServerConn*)pServerArg;
  if( nBuf>0x7fffffff ){ fossil_fatal("SSL read too big"); }
  else if( BIO_eof(pServer->bio) ) return 0;
  while( nBuf!=rc ){
    n = SSL_read(pServer->ssl, zBuf + rc, (int)(nBuf - rc));
    if( n<=0 ){
      break;
    }else if(n>0){
      rc += n;
      if( noLoop ) break;
    }
#ifdef _WIN32
    /* Windows (XP and 10 tested with openssl 1.1.1m and 3.0.1) does
    ** not require reading in a loop, returning all data in a single
    ** call. If we read in a loop on Windows, SSL reads fail. Details:
    ** https://fossil-scm.org/forum/forumpost/2f818850abb72719 */
    break;
#endif
  }
  return rc;
}

/*
** Read a single line of text from the client.
*/