Fossil

Check-in [b63d654041]
Login

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

Overview
Comment:Fix segfault when a chunked reply's first chunk is exactly one byte
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b63d654041f7aee0c01f558dfb0d1c19e46fc8f217300ebd6fde72b868148b07
User & Date: danshearer 2026-07-26 19:55:47.492
Original Comment: Fix segfault if the server replies with just one byte.
Context
2026-07-26
20:00
Fix doc comment typo check-in: 62dc86c231 user: danshearer tags: trunk
19:55
Fix segfault when a chunked reply's first chunk is exactly one byte check-in: b63d654041 user: danshearer tags: trunk
2026-07-25
13:00
When fossil is behaving as an HTTP client, it always uses HTTP/1.1 and it is able to understand the "chunked" transfer-encoding. Also add support for URI values of the form "file://NAME.http-test" which read the HTTP reply text out of the file "NAME.http-test" in the local filesystem, for testing purposes. check-in: c3bd7c3a0e user: drh tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/http.c.
775
776
777
778
779
780
781
782
783
784
785

786
787
788
789
790
791
792
      if( nChunk==0 ){
        /* Final chunk: consume trailer lines up to the terminating blank. */
        sawTerminator = 1;
        while( (zChunk = transport_receive_line(&g.url))!=0 && zChunk[0]!=0 ){}
        break;
      }
      nPrior = blob_size(pReply);
      /* Reserve space without advancing nUsed, so that on error
      ** the blob's reported size equals the bytes actually
      ** received rather the claimed chunk length */
      blob_reserve(pReply, (u64)(nPrior+nChunk));

      {
        unsigned int nRemaining = (unsigned int)nChunk;
        /* transport_receive() may return short; loop until the chunk is
        ** full. */
        while( nRemaining>0 ){
          int nGot;
          nGot = transport_receive(&g.url, &pReply->aData[nPrior], nRemaining);







|
|
<
|
>







775
776
777
778
779
780
781
782
783

784
785
786
787
788
789
790
791
792
      if( nChunk==0 ){
        /* Final chunk: consume trailer lines up to the terminating blank. */
        sawTerminator = 1;
        while( (zChunk = transport_receive_line(&g.url))!=0 && zChunk[0]!=0 ){}
        break;
      }
      nPrior = blob_size(pReply);
      /* Grow the reply buffer, then restore nUsed, so that on error the
      ** blob's reported size is bytes received not claimed chunk length */

      blob_resize(pReply, (u64)(nPrior+nChunk));
      pReply->nUsed = (unsigned int)nPrior;
      {
        unsigned int nRemaining = (unsigned int)nChunk;
        /* transport_receive() may return short; loop until the chunk is
        ** full. */
        while( nRemaining>0 ){
          int nGot;
          nGot = transport_receive(&g.url, &pReply->aData[nPrior], nRemaining);