Fossil SCM
Fix segfault if the server replies with just one byte.
Commit
b63d654041f7aee0c01f558dfb0d1c19e46fc8f217300ebd6fde72b868148b07
Parent
c3bd7c3a0edff89…
1 file changed
+4
-4
+4
-4
| --- src/http.c | ||
| +++ src/http.c | ||
| @@ -777,14 +777,14 @@ | ||
| 777 | 777 | sawTerminator = 1; |
| 778 | 778 | while( (zChunk = transport_receive_line(&g.url))!=0 && zChunk[0]!=0 ){} |
| 779 | 779 | break; |
| 780 | 780 | } |
| 781 | 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)); | |
| 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 | 786 | { |
| 787 | 787 | unsigned int nRemaining = (unsigned int)nChunk; |
| 788 | 788 | /* transport_receive() may return short; loop until the chunk is |
| 789 | 789 | ** full. */ |
| 790 | 790 | while( nRemaining>0 ){ |
| 791 | 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 | /* 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 |