Fossil SCM

Fix segfault if the server replies with just one byte.

danshearer 2026-07-26 19:55 UTC trunk
Commit b63d654041f7aee0c01f558dfb0d1c19e46fc8f217300ebd6fde72b868148b07
1 file changed +4 -4
+4 -4
--- src/http.c
+++ src/http.c
@@ -777,14 +777,14 @@
777777
sawTerminator = 1;
778778
while( (zChunk = transport_receive_line(&g.url))!=0 && zChunk[0]!=0 ){}
779779
break;
780780
}
781781
nPrior = blob_size(pReply);
782
- /* Reserve space without advancing nUsed, so that on error
783
- ** the blob's reported size equals the bytes actually
784
- ** received rather the claimed chunk length */
785
- blob_reserve(pReply, (u64)(nPrior+nChunk));
782
+ /* Grow the reply buffer, then restore nUsed, so that on error the
783
+ ** blob's reported size is bytes received not claimed chunk length */
784
+ blob_resize(pReply, (u64)(nPrior+nChunk));
785
+ pReply->nUsed = (unsigned int)nPrior;
786786
{
787787
unsigned int nRemaining = (unsigned int)nChunk;
788788
/* transport_receive() may return short; loop until the chunk is
789789
** full. */
790790
while( nRemaining>0 ){
791791
--- src/http.c
+++ src/http.c
@@ -777,14 +777,14 @@
777 sawTerminator = 1;
778 while( (zChunk = transport_receive_line(&g.url))!=0 && zChunk[0]!=0 ){}
779 break;
780 }
781 nPrior = blob_size(pReply);
782 /* Reserve space without advancing nUsed, so that on error
783 ** the blob's reported size equals the bytes actually
784 ** received rather the claimed chunk length */
785 blob_reserve(pReply, (u64)(nPrior+nChunk));
786 {
787 unsigned int nRemaining = (unsigned int)nChunk;
788 /* transport_receive() may return short; loop until the chunk is
789 ** full. */
790 while( nRemaining>0 ){
791
--- src/http.c
+++ src/http.c
@@ -777,14 +777,14 @@
777 sawTerminator = 1;
778 while( (zChunk = transport_receive_line(&g.url))!=0 && zChunk[0]!=0 ){}
779 break;
780 }
781 nPrior = blob_size(pReply);
782 /* Grow the reply buffer, then restore nUsed, so that on error the
783 ** blob's reported size is bytes received not claimed chunk length */
784 blob_resize(pReply, (u64)(nPrior+nChunk));
785 pReply->nUsed = (unsigned int)nPrior;
786 {
787 unsigned int nRemaining = (unsigned int)nChunk;
788 /* transport_receive() may return short; loop until the chunk is
789 ** full. */
790 while( nRemaining>0 ){
791

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button