mirror of
https://github.com/curl/curl.git
synced 2026-07-28 04:53:08 +03:00
brotli: data at the end of content can be lost
Decoding loop implementation did not concern the case when all received data is consumed by Brotli decoder and the size of decoded data internally hold by Brotli decoder is greater than CURL_MAX_WRITE_SIZE. For content with unencoded length greater than CURL_MAX_WRITE_SIZE this can result in the loss of data at the end of content. Closes #2194
This commit is contained in:
parent
a0f3eaf25d
commit
58d7cd28a0
3 changed files with 202 additions and 4 deletions
|
|
@ -640,6 +640,7 @@ static CURLcode brotli_unencode_write(struct connectdata *conn,
|
|||
uint8_t *dst;
|
||||
size_t dstleft;
|
||||
CURLcode result = CURLE_OK;
|
||||
BrotliDecoderResult r = BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT;
|
||||
|
||||
if(!bp->br)
|
||||
return CURLE_WRITE_ERROR; /* Stream already ended. */
|
||||
|
|
@ -648,9 +649,8 @@ static CURLcode brotli_unencode_write(struct connectdata *conn,
|
|||
if(!decomp)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
while(nbytes && result == CURLE_OK) {
|
||||
BrotliDecoderResult r;
|
||||
|
||||
while((nbytes || r == BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT) &&
|
||||
result == CURLE_OK) {
|
||||
dst = (uint8_t *) decomp;
|
||||
dstleft = DSIZ;
|
||||
r = BrotliDecoderDecompressStream(bp->br,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue