Fossil

Check-in [acffc8f785]
Login

Check-in [acffc8f785]

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

Overview
Comment: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].
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: acffc8f7858254ebb5c0c06b6af79fbc56085d5d4740047ca5aa46dc89e31689
User & Date: stephan 2022-01-25 18:14:03.118
References
2022-01-26
14:00
Check-in [acffc8f7858254eb] was causing "CGI content-length mismatch" errors on the main Fossil website (xinet.d->althttpd->Fossil). This check-in attempts to resolve the problem. (Edit:) *Not!* The error is still occurring, though at least now we have a better error message. The problem might have been in althttpd and fixed at [https://sqlite.org/althttpd/info/fded041a3e9ce9b0]. ... (check-in: c5c7dd5ffb user: drh tags: trunk)
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: 95256636e4 user: florian tags: ssl-read-loops)
Context
2022-01-25
19:36
Corrected parsing of /json-mode POST data in TLS mode. Extended /json/wiki/preview to support a mimetype option. ... (check-in: 7f5877e843 user: stephan tags: trunk)
18:14
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]. ... (check-in: acffc8f785 user: stephan tags: trunk)
17:44
Update the built-in SQLite to the latest 3.38.0 beta, for the purpose of beta testing SQLite. ... (check-in: 605064e656 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/cgi.c.
1381
1382
1383
1384
1385
1386
1387
1388


1389
1390
1391
1392
1393
1394
1395
       1) If parsing fails, immediately return an error response
       without dispatching the ostensibly-upcoming JSON API.
      */
      cgi_set_content_type(json_guess_content_type());
    }
#endif /* FOSSIL_ENABLE_JSON */
    else{
      blob_read_from_cgi(&g.cgiIn, len);


    }
  }
}

/*
** Decode POST parameter information in the cgiIn content, if any.
*/







|
>
>







1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
       1) If parsing fails, immediately return an error response
       without dispatching the ostensibly-upcoming JSON API.
      */
      cgi_set_content_type(json_guess_content_type());
    }
#endif /* FOSSIL_ENABLE_JSON */
    else{
      if( blob_read_from_cgi(&g.cgiIn, len)!=len ){
        malformed_request("CGI content-length mismatch");
      }
    }
  }
}

/*
** Decode POST parameter information in the cgiIn content, if any.
*/
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
  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;







|



<
<







818
819
820
821
822
823
824
825
826
827
828


829
830
831
832
833
834
835
  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;