Fossil

Diff
Login

Diff

Differences From Artifact [03f3aebccd]:

To Artifact [f0f37b4345]:


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

*/
size_t ssl_read_server(void *pServerArg, char *zBuf, size_t nBuf){
  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;


    }
#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.
*/







>










>
>
>
>
>
>
>
>
>
|
>
>
>


>
>

<
<
<
<
<
<
<







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
844







845
846
847
848
849
850
851
  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.
** Return (size_t)-1 on error.
*/
size_t ssl_read_server(void *pServerArg, char *zBuf, size_t nBuf){
  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 ){
      int error = SSL_get_error(pServer->ssl,n);
      switch( error ){
        case SSL_ERROR_NONE:
        case SSL_ERROR_ZERO_RETURN:
        /* Not all errors relevant with SSL_MODE_AUTO_RETRY. */
        case SSL_ERROR_WANT_READ:
        case SSL_ERROR_WANT_WRITE:
        case SSL_ERROR_WANT_CONNECT:
        case SSL_ERROR_WANT_ACCEPT:
          return rc;
        default:
          return (size_t)-1;
      }
    }else if(n>0){
      rc += n;
      /* SSL_read() returns at most 16 KB of data, so retry in this case. */
      if( n!=16384 ) break;
    }







  }
  return rc;
}

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