Fossil

Check-in [b70557f6]
Login

Check-in [b70557f6]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Simplified version of the previous patch which also catches SSL_read() errors on Windows.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b70557f690594877e44d211ba0a2a3bab16cf7e3e2d2faafb1dfad21675f1705
User & Date: stephan 2022-01-24 08:27:39
References
2022-01-26
07:41
Alternative to [b890451cfb], [b70557f690] and [acffc8f785] to fix the SSL_read() loops on Windows. Pending tests on non-Windows platforms. ... (Closed-Leaf check-in: 95256636 user: florian tags: ssl-read-loops)
Context
2022-01-24
08:42
/chat: added optional 'raw' URL argument to specify that the xmsg text should be returned as-is instead of HTML-izing it. This is not used by /chat but is to support Brad Harder's standalone curses-based /chat client (and similar ones). ... (check-in: 4359f4b5 user: stephan tags: trunk)
08:27
Simplified version of the previous patch which also catches SSL_read() errors on Windows. ... (check-in: b70557f6 user: stephan tags: trunk)
08:23
Preliminary workaround for Windows-specific SSL_read() behavior described in forum post 2f818850abb72719. Patch tested by Florian (Windows) and myself (Linux). ... (check-in: b890451c user: stephan tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/http_ssl.c.

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
  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));
#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 */
    rc += n;
    break;
#else
    if( n==0 ){
      break;
    }else if(n>0){
      rc += n;
    }else{
      fossil_fatal("SSL read error.");
    }






#endif
  }
  return rc;
}

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







<
<
<
<
<
<
<
<







>
>
>
>
>
>







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
  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;
    }else{
      fossil_fatal("SSL read error.");
    }
#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.