bufq: unwrite fix

`Curl_bufq_unwrite()` used the head instead of the tail chunk to shrink
the bufq's content. Fix this and add test case that checks correct
behaviour.

Amended test 2601 accordingly.

Reported-by: Chris Stubbs
Closes #15136
This commit is contained in:
Stefan Eissing 2024-10-03 10:15:07 +02:00 committed by Daniel Stenberg
parent 08d13c0e46
commit 2400a6c6b2
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
4 changed files with 48 additions and 1 deletions

View file

@ -491,7 +491,7 @@ CURLcode Curl_bufq_cwrite(struct bufq *q,
CURLcode Curl_bufq_unwrite(struct bufq *q, size_t len)
{
while(len && q->tail) {
len -= chunk_unwrite(q->head, len);
len -= chunk_unwrite(q->tail, len);
prune_tail(q);
}
return len ? CURLE_AGAIN : CURLE_OK;